Solved

ASP.NET Web Form Variables being reset

Posted on 2016-11-16
2
37 Views
Last Modified: 2016-11-16
Hi all,
I have a Web Form with some code behind variables.  When selecting a grid view control the variables are set; but when pressing a button on the form the variables get reset to when the form was created.  Can someone tell me how to persist variables so that the form refreshing or whatever it's doing wont wipe out my variables?
0
Comment
Question by:Thunder724
2 Comments
 
LVL 28

Accepted Solution

by:
Pawan Kumar earned 500 total points
ID: 41889602
try..

Many Options are there - you can choose based on your need.

ViewState["YourVariable"] = "Pawan";

Session["YourVariable1"] = "Ramesh";

Read more at-

http://www.aspsnippets.com/Articles/Persist-Data-Object-Variable-values-across-PostBack-in-ASPNet.aspx

Hope it helps !!
0
 
LVL 4

Author Closing Comment

by:Thunder724
ID: 41889880
That was very helpful; thank you.
0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

730 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