repeater分页加上搜索功能后,搜索有些关键字分页不正常.比喻:搜索"中"分页不正常,搜索"中国"分页就正常,怪怪怪呀!大侠们进去搜索试试
http://www.17828.cn/catenation/index.aspx关键代码:
if(!IsPostBack)
{
string sSql;
this.key.Text=Request.QueryString["key"]; if(this.key.Text=="")
{
sSql="select id,p_ppmc,p_qyjs,ordertime from catenation where s_flag=1 order by ordertime desc";
}
else
{
sSql="select id,p_ppmc,p_qyjs,ordertime from catenation where s_flag=1 and (p_ppmc like '%"+this.key.Text+"%' or p_qyjs like '%"+this.key.Text+"%' or p_qymc like '%"+this.key.Text+"%' or p_ppjs like '%"+this.key.Text+"%' or p_sshy like '%"+this.key.Text+"%' or j_jmtj like '%"+this.key.Text+"%') order by ordertime desc";
}
PagedDataSource objPage = new PagedDataSource();//创建分页类
objPage.DataSource = Data.GetDataSet(sSql).Tables[0].DefaultView;//设置数据源
objPage.AllowPaging = true;//允许分页
objPage.PageSize = 10;//设置每页显示的项数
int CurPage;//定义变量用来保存当前页索引
if (Request.QueryString["Page"] != null)//判断是否具有页面跳转的请求
CurPage=Convert.ToInt32(Request.QueryString["Page"]);
else
CurPage=1;
objPage.CurrentPageIndex = CurPage-1;//设置当前页的索引
this.lblCurPage.Text = CurPage.ToString();//显示当前页数
this.lblSumPage.Text=objPage.PageCount.ToString();//显示总页数
if (!objPage.IsFirstPage)//如果当前页面不是首页
{
this.lnkPrev.NavigateUrl=Request.CurrentExecutionFilePath+"?Page="+Convert.ToString(CurPage-1)+"&key="+this.key.Text;//定义"上一页"超级链接的URL为:当前执行页面的虚拟路径,并传递下一页面的索引值
this.lnkFirst.NavigateUrl=Request.CurrentExecutionFilePath+"?Page=1&key="+this.key.Text;
}
if (!objPage.IsLastPage)//如果当前页面不是最后一页
{
this.lnkNext.NavigateUrl=Request.CurrentExecutionFilePath+"?Page="+Convert.ToString(CurPage+1)+"&key="+this.key.Text;//定义"下一页"超级链接的URL为:当前执行页面的虚拟路径,并传递下一页面的索引值
this.lnkLast.NavigateUrl=Request.CurrentExecutionFilePath+"?Page="+this.lblSumPage.Text+"&key="+this.key.Text;
} //进行数据绑定
this.Repeater1.DataSource = objPage;
this.Repeater1.DataBind();
}
http://www.17828.cn/catenation/index.aspx关键代码:
if(!IsPostBack)
{
string sSql;
this.key.Text=Request.QueryString["key"]; if(this.key.Text=="")
{
sSql="select id,p_ppmc,p_qyjs,ordertime from catenation where s_flag=1 order by ordertime desc";
}
else
{
sSql="select id,p_ppmc,p_qyjs,ordertime from catenation where s_flag=1 and (p_ppmc like '%"+this.key.Text+"%' or p_qyjs like '%"+this.key.Text+"%' or p_qymc like '%"+this.key.Text+"%' or p_ppjs like '%"+this.key.Text+"%' or p_sshy like '%"+this.key.Text+"%' or j_jmtj like '%"+this.key.Text+"%') order by ordertime desc";
}
PagedDataSource objPage = new PagedDataSource();//创建分页类
objPage.DataSource = Data.GetDataSet(sSql).Tables[0].DefaultView;//设置数据源
objPage.AllowPaging = true;//允许分页
objPage.PageSize = 10;//设置每页显示的项数
int CurPage;//定义变量用来保存当前页索引
if (Request.QueryString["Page"] != null)//判断是否具有页面跳转的请求
CurPage=Convert.ToInt32(Request.QueryString["Page"]);
else
CurPage=1;
objPage.CurrentPageIndex = CurPage-1;//设置当前页的索引
this.lblCurPage.Text = CurPage.ToString();//显示当前页数
this.lblSumPage.Text=objPage.PageCount.ToString();//显示总页数
if (!objPage.IsFirstPage)//如果当前页面不是首页
{
this.lnkPrev.NavigateUrl=Request.CurrentExecutionFilePath+"?Page="+Convert.ToString(CurPage-1)+"&key="+this.key.Text;//定义"上一页"超级链接的URL为:当前执行页面的虚拟路径,并传递下一页面的索引值
this.lnkFirst.NavigateUrl=Request.CurrentExecutionFilePath+"?Page=1&key="+this.key.Text;
}
if (!objPage.IsLastPage)//如果当前页面不是最后一页
{
this.lnkNext.NavigateUrl=Request.CurrentExecutionFilePath+"?Page="+Convert.ToString(CurPage+1)+"&key="+this.key.Text;//定义"下一页"超级链接的URL为:当前执行页面的虚拟路径,并传递下一页面的索引值
this.lnkLast.NavigateUrl=Request.CurrentExecutionFilePath+"?Page="+this.lblSumPage.Text+"&key="+this.key.Text;
} //进行数据绑定
this.Repeater1.DataSource = objPage;
this.Repeater1.DataBind();
}
解决方案 »
- 新手求助:gridview嵌入LinkButton后,LinkButton如何获取gridview相应列(表中某个字段)的值,能在前台直接完成吗!
- ExecuteNonQuery: Connection 属性尚未初始化!!这怎么解决啊!!哪位大哥帮帮忙!
- [2008/07/16]code
- CRM开发页面设计讨论,来者都有分。
- 为什么中文下载链接有的可以,有的不行?
- 大家都用什么样的web在线编辑器!
- 这样的动画可以使用C#编写出来么?大家看看,这个效果感觉很酷,可惜试用版无法保存,但参考一下是很不错的。
- 谁有在datalist中嵌套datalist的例子啊
- 高分求一个源程序~~只要是电子商务就行
- 一个初学网页制作搞不懂的问题?
- .net复杂数据报表显示问题,高手给个思路!
- 为什么用request.files取不到页面<input type="file" size="58"> 里的文件
http://www.17828.cn/catenation/index.aspx?Page=2&key=中
和
http://www.17828.cn/catenation/index.aspx?Page=2&key=%e4%b8%ad的区别!!
this.lnkPrev.NavigateUrl=Request.CurrentExecutionFilePath+"?Page="+Convert.ToString(CurPage-1)+"&key="+ Server.UrlEncode(this.key.Text);
key=Server.UrlDecode(Request.QueryString("key"))
[email protected]
能一个例了给我看看吗,
[email protected]
另开贴100分以表谢意