I have an asp.net page. In the code behind I set a few private variables in order to temporarily store some values. The variables are initially set by user selection from a listview. The variables are getting assigned the correct values. however, by the time the click event for a button is fired the variables are set to null.
what’s going on and how do I fix it ?
Your code-behind classes don’t magically remember variable values. Your page is effectively stateless — either you have to recreate the state on each post-back or persist the values you want in Session or ViewData or in a database.
There is further information on how to implement state in ASP.NET here