Solved

ASP.NET Web Form Variables being reset

Posted on 2016-11-16
2
18 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 18

Accepted Solution

by:
Pawan Kumar Khowal 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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…
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.…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

760 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now