Hi,
i have encountered similar problems in the past as well, please tell me wether you are using this variable within your JS or ASP CS code.
i would like to share with you one handy dandy control - the Hidden Field.
You could change the hidden field value with JavaScript like this:
#region Change Variable
string changevalue = string.Format("javascript:document.getElementById('{0}').value = {1}.options[{1}.selectedIndex].value;", hiddenfield1.ClientID, dropdownlist1.ClientID);
dropdownlist1.Attributes.Add("onChange", changevalue);
#endregion
You can place that code within your formload - PS this cannot be within the
if(!Page.isPostback)
{}
else you will get errors later.
-----------
now what you want is that variable
INT myVariable = int.parse(hiddenfield1.value.Tostring());
Boom.
This variable myVariable should be global, and thus the value can change constantly over multiple events.
if you require this variable to be used cross postback, add it to a session :
session["MyVariable"] = myVariable.Tostring();
or in the querystring :
response.redirect(string.Format("Mypage?variable={0}", myVariable));
Hope this helps.
Regards,