三个dropdownlist
选第一个显示第二个,选第二个显示第三个选第一个:事件DropDownList1_SelectedIndexChanged中
绑定第二个dropdownlist
再做一次就ok了!
做一些判断验证之类的就可以了。。

解决方案 »

  1.   

    两个条件的selectindexchanged事件都调用以下方法
    sqlcommand myquery = new sqlcommand ("select * from tablename where condition1 = '" + dropdownlist1.selecteditem.value + "' and condition2 = '" + dropdownlist2.selectitem.value + "'");
    sqlconnection mycon = new sqlconnection(constring);
    sqldatareader mydr = myquery.executereader();
    dropdownlist3.datasource =mydr;
    dropdownlist3.textfield = "所需字段";
    dropdownlist3.databind();
      

  2.   

    不知道你是不是正如楼上所说的,如果是可以这样:
    private void DropDownList1_SelectedIndexChanged(object sender, System.EventArgs e)
    {
        al=根据SelectedItem.Value查询数据库          foreach(Object in al)
    {
       ListItem list =new ListItem (你要添加的项 ,该项的关键字}
                         this.DropDownList1.Items .Add (list);
    }
    } }
    DropDownList2同样方法做
      

  3.   

    刚才写错拉:
    private void DropDownList1_SelectedIndexChanged(object sender, System.EventArgs e)
    {
        al=根据SelectedItem.Value查询数据库          foreach(Object in al)
    {
       ListItem list =new ListItem (你要添加的项 ,该项的关键字}
                         this.DropDownList2.Items .Add (list);
    }
    } }
    DropDownList2同样方法做
      

  4.   

    刚才写错拉:
    private void DropDownList1_SelectedIndexChanged(object sender, System.EventArgs e)
    {
        ArrayList al=根据SelectedItem.Value查询数据库          foreach(Object in al)
    {
       ListItem list =new ListItem (你要添加的项 ,该项的关键字}
                         this.DropDownList2.Items .Add (list);
    }
    } }
    DropDownList2同样方法做
      

  5.   

    谢谢各位大侠的帮助,我照抄pierven(牛牛)如下代码所示,但是在dropdownlist1里无显示。再次请教高手回答!
     Sub dlHTLB_SelectedIndexChanged(Sender As Object, e As DataGridPageChangedEventArgs)
     Dim strCn As String
       Dim myCd As OleDbCommand
        strCn = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source="&server.mappath("/qkglxt/data/data.mdb")
    dim myquery as oledbcommand
     myquery = new oledbcommand ("select * from expert where e_realm = '" + dlHTLB.SelectedItem.Value + "' and e_zhiwu = '" + dlHTDJ.SelectedItem.Value + "'")
    dim mycon as oledbconnection
    mycon=new oledbconnection(strcn)dim mydr as oledbdatareader
    mydr=myquery.executereader()
    dropdownlist1.datasource =mydr
    dropdownlist1.DataValueField = "e_name"
    dropdownlist1.databind()
    end sub