RadGrid empty after postbacks

5 posts, 0 answers
  1. Narmatha
    Narmatha avatar
    3 posts
    Member since:
    Nov 2010

    Posted 04 Aug 2011 Link to this post

    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.

  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 05 Aug 2011 Link to this post

    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.

  3. Narmatha
    Narmatha avatar
    3 posts
    Member since:
    Nov 2010

    Posted 05 Aug 2011 Link to this post

    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!
  4. William
    William avatar
    1 posts
    Member since:
    Mar 2015

    Posted 19 Sep 2015 Link to this post

    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
  5. Maria Ilieva
    Maria Ilieva avatar
    4017 posts

    Posted 23 Sep 2015 Link to this post

    Hi William,

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

    Maria Ilieva
    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
Back to Top