用AspNetPager分页,点击上一页下一页没反应
用AspNetPager分页,为什么点击上一页下一页,页面显示没变化
protected void AspNetPager1_PageChanging(object src, PageChangingEventArgs e)
{
AspNetPager1.CurrentPageIndex = e.NewPageIndex;
BindData();
}
这个不是触发方法么?
[解决办法]
额··你没确定有总页数 当前页 还有起始页 所以没用··
[解决办法]
我的是
//分页事件
protected void aspNetPager_PageChanging(object src, Wuqi.Webdiyer.PageChangingEventArgs e)
{
aspNetPager.CurrentPageIndex = e.NewPageIndex;
dataBind();
}
aspNetPager.PageSize = PageSize;
PageIndex = aspNetPager.CurrentPageIndex;
ITarticleBusiness tarticleBusiness = factory.GetTarticleBusiness();
ITlmBusiness tlmBusiness = factory.GetTlmBusiness();
//设置gv
string author = txtAuthor.Text.Trim();
string title = txtTitle.Text.Trim();
string lmid = ddlTlm.SelectedValue;//所属栏目
string state = ddlState.SelectedValue;
IList<Varticle> tarticleList = tarticleBusiness.getAllView(author, title, lmid, state, PageIndex, PageSize, out RecordCount);
aspNetPager.RecordCount = RecordCount;//总记录数
if (RecordCount <= 0) aspNetPager.CurrentPageIndex = 1;
bool hasRecord = tarticleList.Count > 0;
//没有数据
if (!hasRecord) { tarticleList.Add(new Varticle()); }
gv.DataSource = tarticleList;
gv.DataBind();
if (!hasRecord)
{
emptyRecord(gv);
}
重点是 aspNetPager.PageSize = PageSize;
PageIndex = aspNetPager.CurrentPageIndex;
aspNetPager.RecordCount = RecordCount;//总记录数
if (RecordCount <= 0) aspNetPager.CurrentPageIndex = 1;