datalist分页出问题了~~~~
private void BindDataList()
{
string userID = Session["usersID"].ToString();
string str = "select * from addresslist where usersID=" + userID;
DataTable dt = new DataTable();
dt = DBOperation.ExecuteDataTable(DBOperation.CONN_STRING_NON_DTC, CommandType.Text, str, null);
if (dt != null && dt.Rows.Count > 0)
{
DataView objView = dt.DefaultView;
PagedDataSource pds = new PagedDataSource();
pds.DataSource = objView;
pds.AllowPaging = true;
pds.PageSize = 4;
pds.CurrentPageIndex = Convert.ToInt32(lblCurrentPage.Text) - 1;
//pds.CurrentPageIndex = int.Parse(ViewState["pageindex"].ToString) ;
//pds.CurrentPageIndex = int.Parse(ViewState["pageindex"].ToString());
LBtnFirst.Enabled = true; //第一页按钮
LBtnLast.Enabled = true; //最后一页按钮
LBtnNext.Enabled = true; //下一页按钮
LBtnPrevious.Enabled = true; //上一页按钮
if (lblCurrentPage.Text == "1")
{
LBtnPrevious.Enabled = false;
LBtnFirst.Enabled = false;
}
if (lblCurrentPage.Text == pds.PageCount.ToString())
{
LBtnNext.Enabled = false;
LBtnLast.Enabled = false;
}
lblSumPage.Text = pds.PageCount.ToString();
DataList1.DataSource = pds;
DataList1.DataBind();
}
}
运行的时候出现的问题:
第一页绑定的数据可以显示,可是第二页的数据就没有显示了
第一页按钮动不了,上一页也动不了, 到了总页数的时候,下一页按钮还是可以使用,
各位大侠帮帮我解释,解释那里出题了??感激涕零~~~~
------解决方案--------------------
点击二页的按钮你绑定了吗?BindDataList()