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

create dynamic column in rad grid

3 Answers 184 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Kiran
Top achievements
Rank 2
Kiran asked on 12 Mar 2012, 11:39 AM
Hi ,
I have RadGrid  created statically and i want to add more column at run-time .
i added but it not work after pagination.

 if (!Page.IsPostBack)
        {
 int count=0;
            foreach (var item in dbContext.STXWEB_EXTRA_COLUMNs.Where(extra=>extra.DLL_NAME==ReportName.Staff))
            {
               
                GridBoundColumn boundColumn;
                boundColumn = new GridBoundColumn();
                StaffReportGridID.MasterTableView.Columns.AddAt(2 + count, boundColumn);
                boundColumn.DataField = item.COLUMN_HEADER;
                boundColumn.HeaderText = item.COLUMN_HEADER;
              
                //  StaffReportGridID.MasterTableView.Columns.Add( boundColumn);
                // StaffReportGridID.MasterTableView.Columns.AddAt(3 + count, boundColumn);
                count++;
           
            }
}

Please let me know is it possible thank u in advance.

thanks 

3 Answers, 1 is accepted

Sort by
0
Accepted
Richard
Top achievements
Rank 1
answered on 14 Mar 2012, 03:54 PM
Kiran:

Please reference the Programmatic Creation documentation page for insights. It states:

RadGrid does not support mixing declarative grid columns with grid columns added dynamically at runtime. You should either create all the columns in the grid programmatically, or else define them all in the ASPX file.

Be sure to view the Grid/OnPageLoad online demo for help in converting to the programmatic creation for all needed columns.


Cheers!
0
Kiran
Top achievements
Rank 2
answered on 20 Mar 2012, 08:15 AM
Thanks for reply.
Yes its working fine, I have created all column programmatic.
thanx for given your valuable time.
0
Marium
Top achievements
Rank 1
answered on 27 Nov 2012, 04:30 PM
Please share the code that worked
Tags
General Discussions
Asked by
Kiran
Top achievements
Rank 2
Answers by
Richard
Top achievements
Rank 1
Kiran
Top achievements
Rank 2
Marium
Top achievements
Rank 1
Share this question
or