例如有1GRIDVIEW控件
数据源默认为 select * ftom stu我想在代码中点击搜索实现如
select * ftom stu where name = {0}
还有
select * ftom stu where name like {0}
或者
select * ftom stu where name like {0} and city ={1}
的情况。怎么设置呀。
数据源默认为 select * ftom stu我想在代码中点击搜索实现如
select * ftom stu where name = {0}
还有
select * ftom stu where name like {0}
或者
select * ftom stu where name like {0} and city ={1}
的情况。怎么设置呀。
这个怎么办怎么动态 设置呀
根据自己需求
if(...........)
{
sql+="where name = {0}";
}
if(...........)
{
sql+="where name like {0}";
}
具体方法如下:
1、由于你的Select * from stu都是一样的,所以可以把条件语句定义为一个字符串(conditionStr)
2、根据不同的搜索条件,更新你的conditionStr,具体方法和antiking(Q狼E行) 说的差不多
3、最好把两个字符串合并。
4、用DataSet或者DataReader(大数据量查询)来绑定你的GridView。