This is a migrated thread and some comments may be shown as answers.

Dynamic column problem

1 Answer 70 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Art
Top achievements
Rank 1
Art asked on 30 Mar 2014, 08:48 AM
Hello,

I am dynamically adding a GridTemplateColumn to a radgrid but the problem is that on each postback a new empty column is added to the grid with header "Action". Any help?

 protected void Page_Init(object sender, EventArgs e)
        {
   
              var col = this.requestGrid.MasterTableView.Columns.FindByUniqueNameSafe("ActionId");
               
                GridTemplateColumn actionColumn = new GridTemplateColumn();
                this.requestGrid.MasterTableView.Columns.Add(actionColumn);
                actionColumn.ItemTemplate = new ActionTemplate("actionID");                                
                actionColumn.DataField = "ActionID";                
                actionColumn.HeaderText = "Action";
        }

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 03 Apr 2014, 08:23 AM
Hi,

Please note that when generating a grid in the Page_Init event handler, grid columns should be added to the Columns collection of the MasterTableView after their attributes are set. Please take a look at this article which discuss about creating template columns programmatically.

Thanks,
Shinu
Tags
Grid
Asked by
Art
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or