有没有办法可以将新更新的数字输入变量?
很抱歉不清楚:/
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 -= flightsTaken;
答案 0 :(得分:1)
您在哪里分配此下拉框的值?它需要在pageload或任何dropdownbox_change事件上完成。回发只会运行page_load并触发事件。
最佳选择是将更新绑定到drowdown_change事件,以更新依赖于其值的任何其他下拉框的值。