SelectedValue return EMPTY in Page_Init

4 posts, 0 answers
  1. Mac
    Mac avatar
    5 posts
    Member since:
    Nov 2007

    Posted 30 Nov 2009 Link to this post

    Dear All,

    I am working on a project with RadMenu and RadGrid. I will define the RadGrid structure programatically in Page_Init method. As long as I change the selected MenuItem, I would like to reload the RadGrid structure based on the configuration by looking into database with RadMenu SelectedValue. However, it doesn't work for me in Page_Init to get SelectedValue of RadMenu. Can anyone help?

    Thanks.
  2. Genady Sergeev
    Admin
    Genady Sergeev avatar
    1600 posts

    Posted 01 Dec 2009 Link to this post

    Hi Mac,

    In order to preserve its SelectedValue property, RadMenu saves it into the ViewState. Unfortunately, the ViewState is not yet available in the Page_Init event and this is why you are not able to access the aforementioned property. The ViewState loading occurs after the Page_Init event and before the Page_Load event. Here is the complete lifecycle:

    1.  Init
    2.  InitComplete
    3.  LoadViewState
    4.  LoadPostbackdata
    5.  PreLoad
    6.  Load
    7.  RaisePostbackEvent
    8.  LoadComplete
    9.  Prerender
    10. PrerenderComplete
    11. SaveViewstate
    12. SaveStateControl
    13. Render
    14. Unload

    I suggest you to hook on event that is after the LoadViewState if you need to use any of the properties of RadMenu.

    I hope this makes sense.

    Kind regards,
    Genady Sergeev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. Mac
    Mac avatar
    5 posts
    Member since:
    Nov 2007

    Posted 01 Dec 2009 Link to this post

    Thanks a lot for your reply.

    However, I still wonder if I could create the GridBoundColumn and GridTemplateColumn for RadGrid dynamically with the help of RadMenu.SelectedValue? So far, it seems I can't create these columns in Page_Load.
  4. Iana Tsolova
    Admin
    Iana Tsolova avatar
    3388 posts

    Posted 04 Dec 2009 Link to this post

    Hi Mac,

    I am afraid that RadGrid does not support mixing declarative and dynamic columns creation as described here. I suggest that you create your grid entirely on Page_Init. There you can try getting the Menu selected value as it is done for a DropDownList control in this help article.

    Greetings,
    Iana
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Back to Top