两个下拉框的内容是一样的,是从数据库绑出来的数据。比如,下拉框ddla和ddlb都绑定的是a,b,c,d。但是我希望第一个选中a后,第二个下拉框就不显示a,同样的,如果我先选择第二个的a,那么第一个下拉框就不显示a。
------解决方案--------------------------------------------------------
在下拉框事件中判断就好了!
------解决方案--------------------------------------------------------
在SelectedIndexChanged 这个事件中逻辑判断下就好了
------解决方案--------------------------------------------------------
用js可以做到无刷新
用后台事件就是刷新
推荐使用无刷新,用户体验好
------解决方案--------------------------------------------------------
给你写了一个!
前台
- HTML code
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True" onselectedindexchanged="DropDownList1_SelectedIndexChanged1"> <asp:ListItem>1</asp:ListItem> <asp:ListItem>2</asp:ListItem> <asp:ListItem>3</asp:ListItem> </asp:DropDownList> <asp:DropDownList ID="DropDownList2" runat="server" AutoPostBack="True" onselectedindexchanged="DropDownList2_SelectedIndexChanged"> <asp:ListItem>1</asp:ListItem> <asp:ListItem>2</asp:ListItem> <asp:ListItem>3</asp:ListItem> </asp:DropDownList>
------解决方案--------------------------------------------------------
------解决方案--------------------------------------------------------
------解决方案--------------------------------------------------------
protected void ddl_sellId_SelectedIndexChanged(object sender, EventArgs e)
{
for (int i = 0; i < ddl_sellId.Items.Count; i++)
{
if (ddl_sellId.SelectedValue == ddl_sellId2.SelectedValue)
{
ddl_sellId2.DataSource=bll.List("ID !=" + Convert.ToInt32(ddlType.SelectedValue) + "");
ddl_sellId2.DataBind();
}
}
}
看看这么写对不对?
------解决方案--------------------------------------------------------
protected void ddl_sellId_SelectedIndexChanged(object sender, EventArgs e)
{
for (int i = 0; i < ddl_sellId.Items.Count; i++)
{
if (ddl_sellId.SelectedValue == ddl_sellId2.SelectedValue)
{
ddl_sellId2.DataSource=bll.List("ID !=" + Convert.ToInt32 (ddl_sellId.SelectedValue) + "");
ddl_sellId2.DataBind();
}
}
}
------解决方案--------------------------------------------------------