(C#)在一个页面中如何实现多个条件的查询
我在一个页面中用四个DropDownList设置了查询条件,可是如何写代码呢?如果用IF是不是太烦琐了点?请各位高手指教
------解决方案--------------------if (this.Drpcondition.SelectedIndex >  0) 
         { 
             string cdition = this.Drpcondition.SelectedValue; 
             string Condition= " ";   
             switch (cdition) 
             { 
                 case  "发表用户 ": 
                     Condition =  "select * from MQ_ALlPhoto where UserName like  '% " + this.txtcondotion.Text.Trim() +  "% ' ";                 
                     break;   
                 case  "标题 ": 
                     Condition =  "select * from MQ_ALlPhoto where Topic like  '% " + this.txtcondotion.Text.Trim() +  "% ' ";                    
                     break;              
             } 
 }
------解决方案--------------------用or咂 
 select * from ... where ...like ... or like .... or like ..... or like ...
------解决方案--------------------dropdownlist 的值是一个arraylist对象了,键值。 你可以第一个选项的值设置为默认的查询条件。