Solved

Nested user controls losing Viewstate

Posted on 2010-09-09
4
502 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
  • 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

863 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

Need Help in Real-Time?

Connect with top rated Experts

27 Experts available now in Live!

Get 1:1 Help Now