首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

(C#)在一个页面中怎么实现多个条件的查询

2011-12-27 
(C#)在一个页面中如何实现多个条件的查询我在一个页面中用四个DropDownList设置了查询条件,可是如何写代码

(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对象了,键值。 你可以第一个选项的值设置为默认的查询条件。

热点排行