Solved

Nested user controls losing Viewstate

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This video discusses moving either the default database or any database to a new volume.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

707 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

12 Experts available now in Live!

Get 1:1 Help Now