get values of GridTemplateColumn's created at run-time

2 posts, 0 answers
  1. Meaning Of Lights
    Meaning Of Lights avatar
    24 posts
    Member since:
    Dec 2007

    Posted 01 Oct 2008 Link to this post

    Hi,

    I have a RadGrid that I dynamically build at runtime, eg:

    templateColumn = new GridTemplateColumn();
                    templateColumn.UniqueName = "Column" + (i + 1).ToString();
                    pt = new PresentationTemplate(0, "OnValueChanged", templateColumn.UniqueName);
                    templateColumn.ItemTemplate = pt;
                    templateColumn.FooterTemplate = new LabelTemplate("0", "lblFooter" + (i + 1).ToString());
                    templateColumn.DataField =  "Column" + i;
                    RadGridGroup.MasterTableView.Columns.Add(templateColumn);



    The template columns only allow numeric inputs.

    I want to get the values of the template columns textboxes, eg:

     foreach (GridDataItem gridRow in RadGridGroup.MasterTableView.Items)
                {
                    RadNumericTextboxExtended textBox = gridRow.FindControl("0Column1") as RadNumericTextboxExtended;



    This works when the columns are specified at design time (in the aspx), how can I get the values of these template column cells when I create the columns at runtime??

    Thanks in advance



  2. Meaning Of Lights
    Meaning Of Lights avatar
    24 posts
    Member since:
    Dec 2007

    Posted 01 Oct 2008 Link to this post

    SOLUTION
    http://www.telerik.com/community/forums/thread/b311D-bbhatk.aspx

    " SAnji | #
    Hi,

        I found the problem. If you create GridTemplateColumn at runtime, you have to build the grid in PageInit event.

    Reference:
    Creating columns on PageLoad when !Page.IsPostBack is not a problem for all column types except for GridTemplateColumns. In order to persist their ViewState you need to generate your grid completely in the code-behind (on PageInit). Thus the template controls will be retained as they will be instantiated before LoadViewState event of the page
                                                              (Grid help document)"

  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top