标记:
<div style="float:left;margin-top:15px;width:80px">
<asp:DropDownList ID="MyList" runat="server" Width="100px"></asp:DropDownList>
</div>
代码:
// clear vehicles list
MyList.Items.Clear();
// add 'all' option
MyList.Items.Add(new ListItem("ALL", "0"));
// add assets
foreach (CustomClass item in items)
MyList.Items.Add(new ListItem(item.Name, item.ID.ToString()));
没有触发 SelectedIndexChanged 的事件,因为它不是必需的。
当我单击回发按钮时,选定项的值仍然是 DropDownList 中第一项的值。我错过了什么?
注意 请停止回复和编辑帖子。我们可以保持原样,因为它已经被回答了。