20分的一道难题..多条件AspNetPager的
我用AspNetPager存储过程可以很轻松的分页.
但是如果涉及到多条件查询的话,应该怎么办呢?
以下是我的多条件查询语句.怎么把这些做成AspNetPager分页.或者其它办法分页..
AspNetPager可以不用存储过程来分页吗?直接T-SQL运行..
string str = "select count(lease_id) as [coun] from lease where lease_daodate > getdate() "; //记录条数
if (Select1.Value != "0 ")
{
str += " and city = ' " + county.Value.ToString() + " ' ";
}
if (Select2.Value != "选择 ")
{
str += " and hx = ' " + Select2.Value.ToString() + " ' ";
}
if (Select3.Value != "选择 ")
{
str += " and fitment = ' " + Select3.Value.ToString() + " ' ";
}
if (txprice1.Value != " " || txprice2.Value != " ")
{
str += " and lease_price > ' " + txprice1.Value.ToString() + " ' and lease_price < ' " + txprice2.Value.ToString() + " ' ";
}
str += " order by id desc ";
str1 += " order by id desc ";
str2 += " order by id desc ";
------解决方案--------------------记住中间要有and,有思路你自己就能写好了
------解决方案--------------------aspnetpager跟数据源无关,所以你用什么都没关系,只要能根据(当前页\页大小\总数)取分页数据
------解决方案--------------------AspNetPager应该和存储过程没关系吧,但是分页的存储过程肯定是最好的选择,你可以找一个通用的分页存储过程
------解决方案--------------------见http://www.cnblogs.com/meetweb/archive/2005/09/13/140239.html
其实最重要的问题就在
Select Top {0} * From User Where user_id Not in ( Select Top {1} user_id From User Order By user_id