Skip to content

DevExpress-Examples/asp-net-mvc-grid-add-column-to-autogenerated-columns

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Grid View for ASP.NET MVC - How to add a column if the AutoGenerateColumns property is set to true

When the AutoGenerateColumns property is set to true, handle the GridViewSettings.DataBound event to add a column to the Grid View. Before adding the column, check whether a column already exists to avoid duplicate columns.

settings.DataBound = (sender, e) => {
    MVCxGridView grid = sender as MVCxGridView;
    if (grid.Columns.IndexOf(grid.Columns["CommandColumn"]) != -1)
        return;
    GridViewCommandColumn col = new GridViewCommandColumn();
    col.Name = "CommandColumn";
    col.ShowSelectCheckbox = true;
    col.VisibleIndex = 0;
    grid.Columns.Add(col);
};

Files to Look At

More Examples

Does this example address your development requirements/objectives?

(you will be redirected to DevExpress.com to submit your response)

About

Add a column to the Grid View when the AutoGenerateColumns property is enabled.

Topics

Resources

License

Stars

Watchers

Forks

Contributors 5