有两个表
一个是表Leibie  字段为 leibie_id,leibie_name
另一个表Lanmu   字段为 lanmu_id,leibie_id,lanmu_name
然后页面上有两个DropDownList控件
用第一个显示Leibie中的内容 用第二个显示Lanmu中的内容
请问怎么写代码将它们关联起来
也就是点击第一个的时候 然后第二个里面出现和它相联系的内容???
请帮一下忙,谢谢了!!!!哪位大哥帮忙把代码写的具体一点
小弟不胜感激!!!!

解决方案 »

  1.   

    找联动DropDownList在搜 索 中有你想要的
      

  2.   

    取第一个DropDownList控件的items[?].value,读取数据库然后帮定到第二个DropDownList控件中.
      

  3.   

    运行后
    我点击第一个dropdownlist的时候选中第二项后
    为什么页面刷新后仍然回到第一项上
      

  4.   

    把 dropdownlist 的 AutoPostBack 设为 True
      

  5.   

    <form id="Form1" method="post" runat="server">
    <FONT face="宋体">
    <asp:DropDownList id="DropDownList1" style="Z-INDEX: 101; LEFT: 256px; POSITION: absolute; TOP: 96px"
    runat="server" AutoPostBack="True"></asp:DropDownList>
    <asp:DropDownList id="DropDownList2" style="Z-INDEX: 102; LEFT: 256px; POSITION: absolute; TOP: 160px"
    runat="server"></asp:DropDownList></FONT>
    </form>
      Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            '在此处放置初始化页的用户代码
            If Not Me.IsPostBack Then
                Dim a As New ArrayList
                Dim i As Integer
                For i = 0 To 5
                    a.Add(i)
                Next
                Me.DropDownList1.DataSource = a
                Me.DropDownList1.DataBind()
            End If
        End Sub    Private Sub DropDownList1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DropDownList1.SelectedIndexChanged
            Dim b As New ArrayList
            Dim x As String
            Dim i As Integer
            For i = 0 To 10
                b.Add(i & Me.DropDownList1.SelectedValue)
            Next
            Me.DropDownList2.DataSource = b
            Me.DataBind()
        End Sub
    记得DropDownList1   AutoPostBack="True"
      

  6.   

    运行后
    我点击第一个dropdownlist的时候选中第二项后
    为什么页面刷新后仍然回到第一项上
    要在page_load中加上 if not ispostback   
    end if