Storing small amount of data in ViewState

Posted on 2014-07-13
Medium Priority
Last Modified: 2014-07-20
Hello, I have a number which is incremented, which needs to be saved and retrieved at various times on postback. Which of the three would be the best method to store the  number/integer.

1. View State
2. A hidden variable on the page.
3. Session variable.

Or can someone rank the above above methods, in regards to which method is best.
Question by:brgdotnet
  • 2
  • 2
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 40193785
"Best" is a subjective term. What does "best" mean to you?

Author Comment

ID: 40194365
Secure, Reliable etc...etc..
LVL 19

Accepted Solution

Manoj Patil earned 920 total points
ID: 40196241
Since the Session Variables are stored on Server side , you can store and retrieve the data easily.
The benefit of this is, you can use session on other pages too, if you want.
Just with the 2 lines of code.

To Store in Session Variable :
int number=10;

To retrieve from Session Variable :

Author Comment

ID: 40198415
Hi, I like Session, but sometimes the data will expire. What is your opinion of using ViewState instead?
LVL 19

Assisted Solution

by:Manoj Patil
Manoj Patil earned 920 total points
ID: 40200228
You can use ViewState but if you want the value on other page, the easiest way is Session.
For session
you can increase the Timeout of Session in your configuration. So that's not the problem.

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Suggested Courses

840 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