-1
我嘗試進行動態DropDownList
這樣:Makinkg動態的DropDownList
<form id="form1" runat="server">
<asp:DropDownList ID="ddlCategory" runat="server" AutoPostBack="True"
onselectedindexchanged="CategoryDropList_SelectedIndexChanged" />
</form>
void DropListInit()
{
Dictionary<string, string> dic = new Dictionary<string, string>();
dic.Add("1","apple");
dic.Add("2","banana");
ddlCategory.DataSource = dic;
ddlCategory.DataTextField = "value";
ddlCategory.DataValueField = "key";
ddlCategory.DataBind();
}
protected void Page_LoadComplete(object sender, EventArgs e)
{
DropListInit();
}
protected void CategoryDropList_SelectedIndexChanged(object sender, EventArgs e)
{
ddlCategory.SelectedValue = ddlCategory.SelectedValue;
}
而且我發現,在沒有沒有這種奇怪的表情ddlCategory.SelectedValue = ddlCategory.SelectedValue;
所以工作時,這是什麼表現手法?或者我做錯了什麼?
當然..它必須工作,謝謝。 – goog