datalist 分页 为什么这个分页不了呢 10
privatevoidBind(DataListdl,stringtable,intStrID){DataSetds=newDataSet();ps.AllowPagin...
private void Bind(DataList dl, string table, int StrID)
{
DataSet ds = new DataSet();
ps.AllowPaging = true;
ps.PageSize = 1;
ds = pp.DataBind(table, StrID);
ps.DataSource = ds.Tables[0].DefaultView;
endpage = ps.PageCount;
ps.CurrentPageIndex=Count ;
dl.DataSource = ps;
dl.DataBind();
if (ps.IsFirstPage)
{
((Button)DataList_Single.Items[0].FindControl("Btn_Up")).Enabled = false;
}
if (ps.IsLastPage)
{
((Button)DataList_Single.Items[0].FindControl("Btn_Last")).Enabled = false;
}
((Label)DataList_Single.Items[0].FindControl("Label15")).Text = ps.CurrentPageIndex.ToString();
}
protected void Btn_Frist_Click(object sender, EventArgs e)
{
int PaperID = Convert.ToInt32(Session["PaperID"].ToString());
Count =0;
Bind(DataList_Single, "Select_Single", PaperID);
}
protected void Btn_Up_Click(object sender, EventArgs e)
{
int PaperID = Convert.ToInt32(Session["PaperID"].ToString());
Count=Count-1;
Bind(DataList_Single, "Select_Single", PaperID);
}
protected void Btn_Next_Click(object sender, EventArgs e)
{
int PaperID = Convert.ToInt32(Session["PaperID"].ToString());
Count=Count+1;
Bind(DataList_Single, "Select_Single", PaperID);
}
protected void Btn_Last_Click(object sender, EventArgs e)
{
int PaperID = Convert.ToInt32(Session["PaperID"].ToString());
Count = ps.PageCount;
Bind(DataList_Single, "Select_Single", PaperID);
}
最后一个ps。pagecount 一直都是1 怎么回事 展开
{
DataSet ds = new DataSet();
ps.AllowPaging = true;
ps.PageSize = 1;
ds = pp.DataBind(table, StrID);
ps.DataSource = ds.Tables[0].DefaultView;
endpage = ps.PageCount;
ps.CurrentPageIndex=Count ;
dl.DataSource = ps;
dl.DataBind();
if (ps.IsFirstPage)
{
((Button)DataList_Single.Items[0].FindControl("Btn_Up")).Enabled = false;
}
if (ps.IsLastPage)
{
((Button)DataList_Single.Items[0].FindControl("Btn_Last")).Enabled = false;
}
((Label)DataList_Single.Items[0].FindControl("Label15")).Text = ps.CurrentPageIndex.ToString();
}
protected void Btn_Frist_Click(object sender, EventArgs e)
{
int PaperID = Convert.ToInt32(Session["PaperID"].ToString());
Count =0;
Bind(DataList_Single, "Select_Single", PaperID);
}
protected void Btn_Up_Click(object sender, EventArgs e)
{
int PaperID = Convert.ToInt32(Session["PaperID"].ToString());
Count=Count-1;
Bind(DataList_Single, "Select_Single", PaperID);
}
protected void Btn_Next_Click(object sender, EventArgs e)
{
int PaperID = Convert.ToInt32(Session["PaperID"].ToString());
Count=Count+1;
Bind(DataList_Single, "Select_Single", PaperID);
}
protected void Btn_Last_Click(object sender, EventArgs e)
{
int PaperID = Convert.ToInt32(Session["PaperID"].ToString());
Count = ps.PageCount;
Bind(DataList_Single, "Select_Single", PaperID);
}
最后一个ps。pagecount 一直都是1 怎么回事 展开
2个回答
展开全部
发现一个明显的问题
private void Bind(DataList dl, string table, int StrID)
private void Bind(ref DataList dl, string table, int StrID)
传引用。默认是传值,可能你设置的对象是实际的datalist的一个副本。
其次可能再分页的时候没有设置datalist的当前dl.CurrentPageIndex=PaperID .
设置后再去绑定。
private void Bind(DataList dl, string table, int StrID)
private void Bind(ref DataList dl, string table, int StrID)
传引用。默认是传值,可能你设置的对象是实际的datalist的一个副本。
其次可能再分页的时候没有设置datalist的当前dl.CurrentPageIndex=PaperID .
设置后再去绑定。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询