Nested user controls losing Viewstate

Hi Experts

I have a user control (a drop down control) nested within another user control (a gridview) and am using Viewstate to keep track of the gridview SortDirection (ASC or DESC). This works fine, until the selected index is changed in the nested control and then that control needs to read this value from ViewState. At this point however the value is Nothing.

Is there a way of persisting Viewstate across nested user controls?

Thanks

Stewart
LVL 2
digital_soulAsked:
Who is Participating?
 
vusovConnect With a Mentor Commented:
Sorry my miss, yes you can use System.Web.HttpContext.Current.Session. But you should remember that Session variable will be available on all pages and user controls.
0
 
vusovCommented:
Try to use HttpContext.Current.ViewState, instead of simple ViewState
0
 
digital_soulAuthor Commented:
'VIewState' is not a member of System.Web.HttpContext so Visual Studio tells me.
0
 
digital_soulAuthor Commented:
Would I be better off just storing this value in the Session?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.