• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 519
  • Last Modified:

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
0
digital_soul
Asked:
digital_soul
  • 2
  • 2
1 Solution
 
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
 
vusovCommented:
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

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now