Explain how to access ViewState value of this page in the next page
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
Kumar Duvvarapu37 reputationPosted Dec 26, 2009, 8:42 PM EST
Viewstate cannot be passed from one aspx page to another page.
But there are alternative way to do so.
1.use the Context to Transfer data to the one page to another.
Page1.aspx.cs
this.Context.Items["EmployeeName"] = "Kumar";
Page2.aspx.cs
string sEmployeeName = this.Context.Items["EmployeeName"].ToString();
2.use the Session Variable
Page1.aspx.cs
Session["EmployeeName"] = "Kumar";
Page2.aspx.cs
string sEmployeeName = Session["EmployeeName"].ToString();
3. User Server.Transfer
4. Cross post back
Hope this will help you
Kirtan PatelRank #292 · 8.6K reputationPosted Dec 26, 2009, 9:20 PM EST
you can use ViewState Same as you use Session but You can not Transfer Value to Another page . it works on Just Same Page
lik
ViewState["test"] = "hello";
Now retrieving it
string x = ViewState["test"].ToString();
it Store the Values in Encrpted form Between the Postbacks as HTML inputs are State Less