Grid is generated in entirety dynamically from the server-side with template fields. Data binding is done using NeedDataSource().After every postback, RadGrid loses the values (and NeedDataSource is not invoked).The column structure for the Grid is defined in OnInit() within if(!isPostback) - so the grid columns are defined only once during the page life cycle.
I remember reading somewhere that when building the Grid structure dynamically from the serverside, the grid 'needs' to be Rebind() on every postback. But even Rebind() does not populate the values of the grid.
Viewstate is turned on for explicitly for the page and the grid.
Does RadGrid not maintain the values on postback when definign the columns during runtime? Is this something to do with ViewState?
I cannot reproduce the issue at my end. Creating columns in the Page_Load event handler does not work for template columns. For the controls inside a template to persist their ViewState, the grid must be generated completely in the code-behind using the Page_Init event and check whether the issue still persists. Check the following help documentation which explains more about this. Programmatic Creation.
Re-read his post, he said he is doing it in page_init, not page_load, as telerik says to do. I am finding the same thing: I dynamically create a radgrid on the server side in page_init, use NeedDataSource(), but the grid does not maintain state on a postback (eg a button click). Should it, and is there any way to make it so? thx
answered on 23 Sep 2015, 12:04 PM
Can you please share your grid configuration so that we can revise it locally and advise you further.
Do you want to have your say when we set our development plans?
Do you want to know when a feature you care about is added or when a bug fixed?
Telerik Feedback Portal
and vote to affect the priority of the items