Issue getting information from database into variable
ok, so i have got a dropdownlist, which contains a number from a database(the amount of seats taken). If the rest of the dropdownboxes change(the flight arrival/departure), the dropdown box with the seats taken box changes to the correct piece of data associated with that flight I am trying to store the seats taken into a variable, however, the number which is stored is the number from the previous value that was in the dropdown box and not the updated value
Is there a way i can get the new updated number into the variable?
Sorry for not being clear :/
int flightsTaken;
string departure, arrival;
departure = Convert.ToString(DropDownListDepartures.Text);
arrival = Convert.ToString(DropDownListArrivals.Text);
//Sets up how many flights are availabe for each departure place
if (departure == "London (Ltn)")
flightsAvailable = 12;
else if (departure == "Edinburgh")
flightsAvailable = 3;
else if (departure == "Manchester")
flightsAvailable = 6;
flightsTaken = Convert.ToInt32(DropDownList2.Text); //THIS GETS THE PREVIOUS NUMBER NOT THE CURRENT NUMBER
flightsAvailable -= flightsTak开发者_如何学Goen;
Where are you assigning the value of this dropdown box? It would need to be done on pageload OR any dropdownbox_change event. A postback will only run the page_load and the event fired.
The best option is to tie the update to the drowdown_change event to update the values of any other dropdown boxes that rely on it's value.
精彩评论