早教吧作业答案频道 -->其他-->
datalist实现分页出问题,publicpartialclassDefault2:System.Web.UI.Page{StudentBusinesssb=newStudentBusiness();PagedDataSourcepds=newPagedDataSource();protectedvoidPageLoad(objectsender,EventArgse){ifthis.Page.IsPostBack){pds.Cu
题目详情
datalist实现分页出问题,
public partial class Default2 :System.Web.UI.Page
{
StudentBusiness sb = new StudentBusiness();
PagedDataSource pds = new PagedDataSource();
protected void Page_Load(object sender,EventArgs e)
{
if this.Page.IsPostBack)
{
pds.CurrentPageIndex = 0;
pds.AllowPaging = true;
pds.PageSize = 3;
dlBind();
}
}
public void dlBind()
{
DataSet ds = sb.GetStudentInfo();
pds.DataSource = ds.Tables[0].DefaultView;
DataList1.DataSource = pds;
DataList1.DataBind();
this.lblTotalCount.Text = ds.Tables[0].Rows.Count.ToString();
btnFirst.Enabled = pds.IsFirstPage;//显示第一页时“首页”按钮不可用
btnPrevious.Enabled = pds.IsFirstPage;//显示第一页时“上一页”按钮不可用
btnNext.Enabled = pds.IsLastPage;//显示最后一页时“下一页”按钮不可用
btnLast.Enabled = pds.IsLastPage;//显示最后一页时“尾页”按钮不可用
lblCurrentPage.Text = Convert.ToString(pds.CurrentPageIndex+1);
lblCountPage.Text = pds.PageCount.ToString();
lblCurrentPageIndex.Text = pds.CurrentPageIndex.ToString();
}
protected void btnFirst_Click(object sender,EventArgs e)
{
pds.CurrentPageIndex = 0;
dlBind();
}
protected void btnPrevious_Click(object sender,EventArgs e)
{
pds.CurrentPageIndex = pds.CurrentPageIndex - 1;
dlBind();
}
protected void btnNext_Click(object sender,EventArgs e)
{
pds.CurrentPageIndex = pds.CurrentPageIndex +1;
dlBind();
}
protected void btnLast_Click(object sender,EventArgs e)
{
pds.CurrentPageIndex = pds.PageCount - 1;
dlBind();
}
}
现在首次加载一切正常,点击"下一页"按钮数据全出现没分页,
public partial class Default2 :System.Web.UI.Page
{
StudentBusiness sb = new StudentBusiness();
PagedDataSource pds = new PagedDataSource();
protected void Page_Load(object sender,EventArgs e)
{
if this.Page.IsPostBack)
{
pds.CurrentPageIndex = 0;
pds.AllowPaging = true;
pds.PageSize = 3;
dlBind();
}
}
public void dlBind()
{
DataSet ds = sb.GetStudentInfo();
pds.DataSource = ds.Tables[0].DefaultView;
DataList1.DataSource = pds;
DataList1.DataBind();
this.lblTotalCount.Text = ds.Tables[0].Rows.Count.ToString();
btnFirst.Enabled = pds.IsFirstPage;//显示第一页时“首页”按钮不可用
btnPrevious.Enabled = pds.IsFirstPage;//显示第一页时“上一页”按钮不可用
btnNext.Enabled = pds.IsLastPage;//显示最后一页时“下一页”按钮不可用
btnLast.Enabled = pds.IsLastPage;//显示最后一页时“尾页”按钮不可用
lblCurrentPage.Text = Convert.ToString(pds.CurrentPageIndex+1);
lblCountPage.Text = pds.PageCount.ToString();
lblCurrentPageIndex.Text = pds.CurrentPageIndex.ToString();
}
protected void btnFirst_Click(object sender,EventArgs e)
{
pds.CurrentPageIndex = 0;
dlBind();
}
protected void btnPrevious_Click(object sender,EventArgs e)
{
pds.CurrentPageIndex = pds.CurrentPageIndex - 1;
dlBind();
}
protected void btnNext_Click(object sender,EventArgs e)
{
pds.CurrentPageIndex = pds.CurrentPageIndex +1;
dlBind();
}
protected void btnLast_Click(object sender,EventArgs e)
{
pds.CurrentPageIndex = pds.PageCount - 1;
dlBind();
}
}
现在首次加载一切正常,点击"下一页"按钮数据全出现没分页,
▼优质解答
答案和解析
下一页后blCurrentPageIndex 和lblCountPage显示正常吗?
看了 datalist实现分页出问...的网友还看了以下:
某溶液中含有Ba,Cu,Ag,现用NaOH溶液.盐酸和NaSO(4)溶液将这三种离子逐一沉淀分离. 2020-05-02 …
Cu+在酸性溶液中不稳定,可发生自身氧化还原反应生成Cu2+和Cu。现有浓、稀硫酸,FeCl3溶液 2020-05-13 …
Cu+在酸性溶液中不稳定,可发生自身氧化、还原反应生成Cu2+和Cu,现有浓硫酸、浓硝酸、稀H2S 2020-05-13 …
2010济南中考化学,只需解释第(4)题.现欲探究一固体混合物A的成分,已知其中可能含有CuCl2 2020-05-13 …
在研究金矿床物质组分的过程中,通过分析发现了Cu-Ni-Zn-Sn-Fe多金属互化物.(1)某种金 2020-06-09 …
科研小组为探究氮的化合物性质,按如图连接好装置,进行实验.将C处Pt丝加热至红热,再将A试管中物质 2020-06-11 …
Cu在Cl2中燃烧的化学方程式为Cu+Cl2现象:。溶于水,溶液为色或色。Fe在Cl2中燃烧的化学 2020-07-12 …
高二学定积分,如题,现在完全搞不懂怎么做题,我觉得自己太笨了,看着大家每天都能写完的作业,我是打心 2020-07-22 …
单质碳和氧化铜在一定温度下反应时,氧化铜可被还原为Cu2O、Cu.现将2.00gC与16.0gCuO 2020-12-24 …
口语三个fair19分,如题.现在总分103,口语19分,三个fair,想复议到20.看了一下三个f 2021-01-14 …