好像没有填充dt表吧 
sqldataadapter 填充dt表 试试 

解决方案 »

  1.   

    string cmdText ="";
    if(DropDownList4.selectValue.ToString()="")
    {
    cmdText = "select * from Student where Scol='" + DropDownList4.selectValue.ToString() + "'and Sdept='" + DropDownList5.selectValue.ToString() + "'and Sclass='" + DropDownList3.selectValue.ToString() + "'";
    }
    else
    {
    .....
    }
      

  2.   

    十分感谢,明白了,如果我还想做两级联动
    <asp:DropDownList ID="DropDownList4" runat="server" AutoPostBack="True" DataSourceID="SqlDataSource4" DataTextField="colName" DataValueField="classId">
                    </asp:DropDownList></td>
                <td style="width: 68px; height: 26px;">
                    专业:</td>
                <td style="width: 38px; height: 26px">
                    <asp:DropDownList ID="DropDownList5" runat="server" AutoPostBack="True" DataSourceID="SqlDataSource3" DataTextField="deptName" DataValueField="classId">
                    </asp:DropDownList></td>
    用DropDownList4.selectValue.ToString() 就不起作用了该怎么办?
      

  3.   

    填充过了,dt = Teacher.SelectRecords(cmdText); 写在Teacher类里了
      

  4.   

    DropDownList4.SelectedItem.Text
    条件 不是Text
      

  5.   

    这个我知道了。已经解决DropDownList4.selectValue.ToString() 就可以,只是现在还想做联动,如4楼所写,不知道怎样处理
      

  6.   

    删除 this.GridView1.DataSourceID = null; 
    字段绑定是否正确
      

  7.   

    呵呵,楼主很有可能没有设置dropdownlist的是否回发属性,当然就不会有东西在gridview里显示了!!!
      

  8.   

    具体怎样做,我没有写代码是直接用控件进行绑定的,
    <asp:DropDownList ID="DropDownList4" runat="server" AutoPostBack="True" DataSourceID="SqlDataSource4" DataTextField="colName" DataValueField="classId"
                    </asp:DropDownList> </td> 
                <td style="width: 68px; height: 26px;"> 
                    专业: </td> 
                <td style="width: 38px; height: 26px"> 
                    <asp:DropDownList ID="DropDownList5" runat="server" AutoPostBack="True" DataSourceID="SqlDataSource3" DataTextField="deptName" DataValueField="classId"> 
                    </asp:DropDownList> </td> 
    这样就可以连起来,我设了个Button来进行搜索相应数据,但是搜索不出来。