aspnetpager 删除_AspNetPager 删除_aspnetpager(2)

电脑杂谈  发布时间:2017-02-23 08:31:21  来源:网络整理

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

相关阅读
    发表评论  请自觉遵守互联网相关的政策法规,严禁发布、暴力、反动的言论

    热点图片
    拼命载入中...