不管我做什麼,或者嘗試下拉列表不只是工作,替代ASP.NET下拉列表
<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 ");
}
}