Solved

Nested user controls losing Viewstate

Posted on 2010-09-09
4
508 Views
Last Modified: 2012-05-10
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
Comment
Question by:digital_soul
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 3

Expert Comment

by:vusov
ID: 33636351
Try to use HttpContext.Current.ViewState, instead of simple ViewState
0
 
LVL 2

Author Comment

by:digital_soul
ID: 33636407
'VIewState' is not a member of System.Web.HttpContext so Visual Studio tells me.
0
 
LVL 2

Author Comment

by:digital_soul
ID: 33636458
Would I be better off just storing this value in the Session?
0
 
LVL 3

Accepted Solution

by:
vusov earned 500 total points
ID: 33636560
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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question