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

get values of GridTemplateColumn's created at run-time

1 Answer 88 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Meaning Of Lights
Top achievements
Rank 2
Meaning Of Lights asked on 02 Oct 2008, 01:30 AM
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



1 Answer, 1 is accepted

Sort by
0
Meaning Of Lights
Top achievements
Rank 2
answered on 02 Oct 2008, 03:33 AM
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)"

Tags
Grid
Asked by
Meaning Of Lights
Top achievements
Rank 2
Answers by
Meaning Of Lights
Top achievements
Rank 2
Share this question
or