AspNetPage的分页,那个看下,帮忙啊
WebClass ddw = new WebClass();
const string vsKey = "searchCriteria ";
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
Label1.Text = Request.QueryString[ "stype "].ToString();
Label2.Text = Request.QueryString[ "stype "].ToString();
searchOrders(Request .QueryString[ "stype "]);
}
}
void searchOrders(string sWhere)
{
string sql = "select * from daili_yufu where username= ' "+Request.Cookies[ "CookieTimes "].Value.ToString()+ " ' and yftype= ' "+sWhere+ " ' order by id desc ";
AspNetPager1.RecordCount = ddw.dt(sql).Rows.Count;
System.Text.StringBuilder sb = new System.Text.StringBuilder();
PagedDataSource pds = new PagedDataSource();
pds.DataSource = ddw.dt(sql).DefaultView;
pds.AllowPaging = true;
pds.CurrentPageIndex = AspNetPager1.CurrentPageIndex - 1;
pds.PageSize = AspNetPager1.PageSize;
Repeater1.DataSource = pds;
Repeater1.DataBind();
}
protected void AspNetPager1_PageChanged(object src, EventArgs e)
{
searchOrders((string)ViewState[vsKey]);
}
刚开始很好,但一点下一页,就没数据了,第二页应该有数据的!不知道为什么没了啊,那个帮忙看看!
------解决方案--------------------把给RecordCount赋值的代码放到Page_Load方法中调用searchOrders之前,否则太迟了,RecordCount就变成0了