有一个多条件查询表单其中有一个搜索项color,使用两个DropdownList 其中的项目都是("d","e","f","g","h","i","j","k“,"m","n","o-p","w-x","z","fancy")
选择这两个DropdownList以划定范围,比如:DropdownList1选择"e",DropdownList2选择"g",就是查询数据库中color字段匹配("e","f","g")的条目请问大家这样的查询如何实现?如能解决,高分伺候!

解决方案 »

  1.   

    先定义两个string型的变量接收dropdownlist选择的文本
    string a = dropdownlist1.SelectedItem.Text;
    string b = dropdownlist2.SelectedItem.Text;
    select color from 表名 where color between '"+a+"' and '"+b+"';
      

  2.   

    你在数据库里面保存的时候把那个字段保存为int的
    ("d","e","f","g","h","i","j","k“,"m","n","o-p","w-x","z","fancy") 
    分别对应1 2 3 4 5 6 7 8 9 10 11 12 13 14
    那DropdownList1选择"e",DropdownList2选择"g",就是查询数据库中color字段在2和4之间的
      

  3.   

    纯between不行,如果前面大,后面小查不到数据了,
    定义个方法判断,把条件结果返回
      

  4.   

    用ajax,前臺用兩個WEB控件Select,定義select的函數
    <select id="Select1" style="width: 200px" runat="server" onchange="SelectBranch(this.value)" >
    <script>
    function SelectBranch(va)
    {
        if(va!='0')
        {
    var txt11 = document.getElementById("TextBox11");
        txt11.value=va;   
    var select2 = document.getElementById("Select2");
    select2.disabled=false;
    var select3 = document.getElementById("Select3");
        select3.disabled=true;
    select3.options.length=1;
    var url="Handler.ashx?type=branch&id="+va+"";
    send_request("GET",url,null,"text",populateClass3);
        }
    }
    傳值到下一個Select就可以啊