[英]Alternative to ASP.NET drop down list
不管我做什么,還是嘗試下拉列表不僅有效,
<asp:DropDownList ID="drop1" runat="server" AutoPostBack="true" enabledviewstate="true" OnClick="Drop1_SelectedIndexChanged" />
綁在這里
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
BindDropDownList();
}
//drop1.SelectedIndexChanged += new EventHandler(Drop1_SelectedIndexChanged);
}
這是永遠不會觸發的方法(我使用斷點進行檢查)
protected void Drop1_SelectedIndexChanged(object sender, EventArgs e)
{
//checkboxlist1.Items.Add("hahahha");
}
有其他選擇嗎?????????? 我需要使用以下命令填充下拉列表,
using (SqlDataSource ds = new SqlDataSource(ConnectionString(), SelectCommand()))
{
System.Data.DataView dv = (System.Data.DataView)ds.Select(DataSourceSelectArguments.Empty);
if (dv.Count > 0)
{
drop1.DataSource = ds;
drop1.DataTextField = "UserName";
drop1.DataBind();
drop1.Items.Insert(0, "Please select a Username ");
}
}
沒有為DropDownList
定義Click
事件。 要使用的事件是SelectedIndexChanged :
<asp:DropDownList ID="drop1" runat="server"
AutoPostBack="true"
EnabledViewState="true"
OnSelectedIndexChanged="Drop1_SelectedIndexChanged" />
而是您鍵入OnClick
OnSelectedIndexChanged
聲明dropdownlist如下:
<asp:DropDownList ID="drop1" runat="server" AutoPostBack="true" enabledviewstate="true" OnSelectedIndexChanged="Drop1_SelectedIndexChanged" />
Dropdownlist不存在Onclick事件,Dropdownlist使用OnSelectedIndexChanged事件。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.