protected string strKeyWord = "";
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
strKeyWord = Request.Form["txtKeyWord"].Trim();
string strQuery = " Title Like '%" + strKeyWord + "%'";
ViewState[vsKey] = strQuery;
searchOrders(strQuery);
}
}
void searchOrders(string sWhere)
{
DataSet ds1 = NewsBll.GetList("*", sWhere, " ID DESC");
AspNetPager1.RecordCount = ds1.Tables[0].Rows.Count;
PagedDataSource pds = new PagedDataSource();
pds.DataSource = ds1.Tables[0].DefaultView;
pds.AllowPaging = true;
pds.CurrentPageIndex = AspNetPager1.CurrentPageIndex - 1;
pds.PageSize = AspNetPager1.PageSize;
RPNewsList.DataSource = pds;
RPNewsList.DataBind();
}
protected void AspNetPager1_PageChanged(object src, EventArgs e)
{
searchOrders((string)ViewState[vsKey]);
}
最后的问题,求搜索后的url分页即带参数?page=的方式的解决办法
你把你搜索后的条件存起来,下次post的时候 在用 const string vsKey = "searchCriteria"; //ViewState key
protected string strKeyWord = "",strQuery;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
if (Request.Form["txtKeyWord"].Trim() != null)
{
strKeyWord = Request.Form["txtKeyWord"].Trim();
strQuery = " Title Like '%" + strKeyWord + "%'";
ViewState[vsKey] = strQuery;
searchOrders(strQuery);
}
else
{
}
}
}
void searchOrders(string sWhere)
{
DataSet ds1 = NewsBll.GetList("*", sWhere, " ID DESC");
AspNetPager1.RecordCount = ds1.Tables[0].Rows.Count;
本文来自电脑杂谈,转载请注明本文网址:
https://www.pc-fly.com/a/jisuanjixue/article-34005-2.html
不行贿