Im trying to increment this specific element in ASPnet. A user selects a specific item in the dropdown box, and it increases the quantity as the user selects.
If DropDownList1.SelectedIndex = 1 Then
DropDownList1.SelectedIndex = 0
intDonutqty += 1
txtDonut.Text = intDonutqty
End If
Everything else works fine, but for some reason it just stays at 1 without incrementing.
Thanks for the help
Variables in the page are local to the instance of the
Pageclass, and the instance is only used to handle one request. When you make a postback and the next request comes for the page, a new instance of the Page class is created, so you will get a brand new variable which starts out at zero.To keep the value between requests, you either have to store it in a session variable, in the ViewState, in a cookie, or a hidden field in the form.