62,041
社区成员
发帖
与我相关
我的任务
分享
<asp:dropdownlist id="DropDownList1 " autopostback="true" onselectedindexchanged="DropDownList1_SelectedIndexChanged" runat="server"></asp:dropdownlist>
ItemDataBound中
if (e.Item.ItemType == ListItemType.Item||e.Item.ItemType==ListItemType.AlternatingItem||e.Item.ItemType==ListItemType.EditItem)
{
DropDownList myDrop = e.Item.FindControl("DropDownList1 ") as DropDownList;
if (myDrop.Items.Count == 0)
{
myDrop.Items.Add(new ListItem("a", "1"));
myDrop.Items.Add(new ListItem("b", "2"));
myDrop.DataBind();
}
}
protected void DropDownList1_SelectedIndexChanged(object sender,EventArgs e)
{
var selectvalue=((DropDownList)sender).SelectedIndex.ToString();//得到DropDownList1选中的值
//然后查询数据库绑定
for(int i=0;i<rp.rows.count;i++)
{
//循环遍历招待第二个DropDownList2 然后绑定
}
}