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();
}

解决方案 »

  1.   

    建议使用: URLEncode 和 URLDecode
      

  2.   

    试试
    http://www.17828.cn/catenation/index.aspx?Page=2&key=中

    http://www.17828.cn/catenation/index.aspx?Page=2&key=%e4%b8%ad的区别!!
      

  3.   


    this.lnkPrev.NavigateUrl=Request.CurrentExecutionFilePath+"?Page="+Convert.ToString(CurPage-1)+"&key="+ Server.UrlEncode(this.key.Text);
    key=Server.UrlDecode(Request.QueryString("key"))
      

  4.   

    谢谢jamex(1 + 1 = 爱),问题解决,高手呀你有用存储过程写的搜索分页程序吗,能一个例了给我看看吗,
    [email protected]
      

  5.   

    哪位前辈有用存储过程写的搜索分页程序吗,(c#代码分离版)(最好有对代码的注释)
    能一个例了给我看看吗,
    [email protected]
    另开贴100分以表谢意