create dynamic column in rad grid

4 posts, 1 answers
  1. Kiran
    Kiran avatar
    6 posts
    Member since:
    Jan 2012

    Posted 12 Mar 2012 Link to this post

    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);

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


  2. Answer
    Richard avatar
    479 posts
    Member since:
    Nov 2011

    Posted 14 Mar 2012 Link to this post


    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.

  3. Kiran
    Kiran avatar
    6 posts
    Member since:
    Jan 2012

    Posted 20 Mar 2012 Link to this post

    Thanks for reply.
    Yes its working fine, I have created all column programmatic.
    thanx for given your valuable time.
  4. Marium
    Marium avatar
    2 posts
    Member since:
    Nov 2012

    Posted 27 Nov 2012 Link to this post

    Please share the code that worked
Back to Top