![](/img/trans.png)
[英]DropDownList in Repeater control, can't fire SelectedIndexChanged
[英]DropDownList: SelectedIndexChanged do not fire
我在頁面加載中填寫了一個ASP Dropdownlist
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
for (int i = 0; i < _maxStationsAnz; i++)
{
String stations = arrayList[1];
_allData = stations.Split(Convert.ToChar("/"));
_data = _allData[i].Split(Convert.ToChar(";"));
ddWeatherstations.Items.Add(_data[0]);
}
}
選擇新電台后,它應更新信息。 我在aspx網站上使用OnSelectedIndexChanged
屬性。
我后面的代碼:
protected void ddWeatherstations_SelectedIndexChanged(object sender, EventArgs e)
{
for (int i = 0; i < _maxStationsAnz; i++)
{
if (ddWeatherstations.SelectedIndex == i)
{
lselected.Text = "Index changed!";
//unimportant code
//....
}
}
}
當我設置一個斷點並運行程序並更改下拉列表的值時,什么也沒有發生。
您需要將下拉列表ddWeatherstations
AutoPostBack
屬性設置為True
。
嘗試這個:
<asp:DropDownList ID="ddWeatherstations" runat="server" AutoPostBack="true"
OnSelectedIndexChanged="ddWeatherstations_SelectedIndexChanged">
</asp:DropDownList>
您需要設置屬性AutoPostBack="true"
但是每次您選擇DropDownList的其他索引時,這都會回發所有頁面,因此我建議您將DropDownList放入AJAX更新面板中。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.