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

SelectedValue return EMPTY in Page_Init

3 Answers 107 Views
Menu
This is a migrated thread and some comments may be shown as answers.
Mac
Top achievements
Rank 2
Mac asked on 30 Nov 2009, 11:22 AM
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.

3 Answers, 1 is accepted

Sort by
0
Genady Sergeev
Telerik team
answered on 01 Dec 2009, 01:25 PM
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.
0
Mac
Top achievements
Rank 2
answered on 02 Dec 2009, 01:54 AM
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.
0
Iana Tsolova
Telerik team
answered on 04 Dec 2009, 12:51 PM
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.
Tags
Menu
Asked by
Mac
Top achievements
Rank 2
Answers by
Genady Sergeev
Telerik team
Mac
Top achievements
Rank 2
Iana Tsolova
Telerik team
Share this question
or