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

RFE: RadGrid ViewState management improvement

1 Answer 74 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Christer
Top achievements
Rank 1
Christer asked on 20 Feb 2009, 07:58 AM
In our project we had an issue with the RadGrid event method. The event method was not triggered although a postback did occur. Apparantly this was due to the following code:

   GridBoundColumn boundColumn = new GridBoundColumn();
   boundColumn.DataField = "CustomerID";
   boundColumn.HeaderText =
"CustomerID";
   RadGrid1.MasterTableView.Columns.Add(boundColumn);               

The problem was that the .DataField and .HeaderText properties were set BEFORE the GridBoundColumn object was added to the MasterTableView columns collection. According to the documentation of the RadGrid (http://www.telerik.com/help/aspnet-ajax/grdprogrammaticcreation.html): "Columns and detail table should be added to the corresponding collection first, before the values for their properties are set. This is important because no ViewState is managed for the object before it has been added to the corresponding collection.". However, this requirement is rather unorthodox and differs from other equivalent web controls. And that this would result in that event methods will not be triggered is not easy to identify. At least, the documentation should be more clear on this issue and the methods and properties should have comments regarding this requirement.

Christer Lundhag

1 Answer, 1 is accepted

Sort by
0
Rosen
Telerik team
answered on 24 Feb 2009, 07:27 AM
Hi Christer,

The behavior in question is a general ASP.NET behavior. In order control to track its changes properly when added after the init phase of page's lifecycle it should first be added to its parent's Controls collection. For more information about ViewState and the behavior in question please refer to this blog post.

Best wishes,
Rosen
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Grid
Asked by
Christer
Top achievements
Rank 1
Answers by
Rosen
Telerik team
Share this question
or