Click here to Skip to main content
15,886,664 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
How do you declare viewstate variable for string and store it in a string variable?
Posted

For storing :
C#
ViewState["YourKey"]= "YourValue";

For getting :
C#
string yourvalue = ViewState["YourKey"]


Please refer following links :

Beginner's Guide To View State[^]
ASP.NET Web Forms - Maintaining the ViewState[^]
ASP.NET View State Overview[^]

Good luck
 
Share this answer
 
Comments
polkj 9-Jul-14 11:02am    
How do I store the value in ifpostback and in if or else if statement how do I access to my viewstate value
Raje_ 9-Jul-14 11:05am    
Please go through the link :)
C#
ViewState["yourStringViewStateID"] = "a string";

string str = ViewState["yourStringViewStateID"]; 


str will have "a string" inside.

is that all you need to know?
 
Share this answer
 
Comments
polkj 9-Jul-14 11:09am    
Nope. How do I store my viewstate values in ispostback and un my if else if statement how do i access to my viewstate values?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900