我做了两个下拉列表:
部门:
<asp:DropDownList runat="server" id="BM" DataTextField="BMMC" />
二级部门:
<asp:DropDownList runat="server" id="SubBM" DataTextField="SubBMMC" />
下拉列表的数据在前面绑定,可是不知道怎么实现,请帮忙!!!
对于部门下拉列表的数据我是这样处理的:(请指教)
Dim mycommand1 As SqlCommand 
mycommand1 = new SqlCommand("select BMMC from T_BM",myconn)
myconn.open()
Dim dr1 As SqlDataReader = mycommand1.ExecuteReader()
BM.DataSource = dr1
BM.DataBind()
myconn.close()
关于二级部门下拉列表的数据再这样写一遍的话总是有错误,本人是初学者请多多指教!!

解决方案 »

  1.   

    二级部门下拉列表的数据你可以写在部门下拉列表的selectindexchanged事件中,这样可以根据选择的部门去查所属的二级部门
      

  2.   

    写在selectindexchanged里面
    并且加上
    if  is not me.postback then
    end if 
    判断
      

  3.   

    用两个dropdownlist的selectindexchanged事件搞定就得了
      

  4.   

    又遇到问题了!我想在部门下拉列表中的默认项设为“请选择”
    可是总是显示不出来,请帮我看看呀!
    Sub Page_Load(sender As Object, e As Eventargs)
    If not IsPostBack
    mycommand = new SqlCommand("select BMMC from T_BM",myconn)
    myconn.open()
    Dim dr1 As SqlDataReader = mycommand.ExecuteReader()
    BM.DataSource = dr1
    BM.DataBind()
    myconn.close()
    End If
    End Sub 
    部门:<asp:DropDownList runat="server" id="BM" DataValueField="BMMC" OnSelectedIndexChanged="subbm_click" >
             <asp:ListItem Value="00" Selected="True">请选择</asp:ListItem>               </asp:DropDownList>
    请再帮帮忙!!