Explain how to access ViewState value of this page in the next page
Explain how to access ViewState value of this page in the next page?
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Kirtan PatelPosted Dec 27, 2009, 2:20 AM
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
Kumar DuvvarapuPosted Dec 27, 2009, 1:42 AM
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