我有一個DropDownList連接到ObjectDataSource。在我的頁面加載中,我根據情況將selectedvalue設置爲特定值。我怎樣才能在我的方法selectedindexchanged「重置」選定的值,所以你仍然可以選擇其他選項?或者我不應該使用selectedvalue來設置下拉列表的默認值?Dropdownlist重置SelectedValue
<asp:DropDownList ID="DropDownList" runat="server" DataSourceID="ObjectDataSource" DataTextField="Type" DataValueField="TypeId"
AutoPostBack="true" onselectedindexchanged="DropDownList_SelectedIndexChanged" >
</asp:DropDownList>
protected void Page_Load(object sender, EventArgs e)
{
int default = category.TypeId;
DropDownList.SelectedIndex = default;
}
protected void DropDownList_SelectedIndexChanged(object sender, EventArgs e)
{
int id = int.Parse(DropDownList.SelectedValue);
Session["id"] = id;
}
你請了一些代碼,詳細點嗎? – sarwar026 2012-04-12 11:39:55
編輯我的問題 – 2012-04-12 12:01:52