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

RadGrid empty after postbacks

4 Answers 106 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Narmatha
Top achievements
Rank 1
Narmatha asked on 04 Aug 2011, 08:49 PM

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?

Appreciate all the help.

4 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 1
answered on 05 Aug 2011, 05:48 AM
Hello Narmatha,

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.

Thanks,
Princy.
0
Narmatha
Top achievements
Rank 1
answered on 05 Aug 2011, 02:17 PM
Hi Princy,

Thanks for the expedited response. I do create the template columns during OnInit(). I'll be wrapping this solution and submitting a support ticket to let you take a look at the code. Thanks much!
0
William
Top achievements
Rank 1
answered on 19 Sep 2015, 05:31 PM
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
0
Maria Ilieva
Telerik team
answered on 23 Sep 2015, 12:04 PM
Hi William,

Can you please share your grid configuration so that we can revise it locally and advise you further.

Regards,
Maria Ilieva
Telerik
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? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
Grid
Asked by
Narmatha
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 1
Narmatha
Top achievements
Rank 1
William
Top achievements
Rank 1
Maria Ilieva
Telerik team
Share this question
or