关于datalist嵌套后,内部datalist分页的数据绑定问题?
如题,datalist嵌套后,内部datalist需要分页,而分页时有四个linkbutton,分别链接上下首末页,请问这四个linkbutton怎样去绑定关于内部dat...
如题,datalist嵌套后,内部datalist需要分页,而分页时有四个linkbutton,分别链接上下首末页,请问这四个linkbutton怎样去绑定关于内部datalist分页的数据?
展开
1个回答
展开全部
if (dataList1 != null)
{
string ID = Request.QueryString["ID"].ToString();
SqlConnection con1 = DC.getCon();
int curpage = Convert.ToInt32(((Label)e.Item.FindControl("labPage")).Text);
PagedDataSource pds = new PagedDataSource();
string strSql1 = "select * from anliDisplayImg where anliDisplayID='" + ID + "' order by anliDisplayImgDate desc ";
SqlDataAdapter sda1 = new SqlDataAdapter();
sda1.SelectCommand = new SqlCommand(strSql1, con1);
DataSet ds1 = new DataSet();
sda1.Fill(ds1, "fill1");
pds.DataSource = ds1.Tables["fill1"].DefaultView;
pds.AllowPaging = true; pds.PageSize = 4; pds.CurrentPageIndex = curpage - 1; //this.GridView1.DataKeyNames = new string[] { "renID" };
((LinkButton)e.Item.FindControl("lnkbtnUp")).Enabled = true;
((LinkButton)e.Item.FindControl("lnkbtnNext")).Enabled = true;
((LinkButton)e.Item.FindControl("lnkbtnBack")).Enabled = true;
((LinkButton)e.Item.FindControl("lnkbtnOne")).Enabled = true;
if (curpage == 1)
{
((LinkButton)e.Item.FindControl("lnkbtnOne")).Enabled = false;
((LinkButton)e.Item.FindControl("lnkbtnUp")).Enabled = false;
}
if (curpage == pds.PageCount)
{
((LinkButton)e.Item.FindControl("lnkbtnNext")).Enabled = false;
((LinkButton)e.Item.FindControl("lnkbtnBack")).Enabled = false;
}
((Label)e.Item.FindControl("labBackPage")).Text = Convert.ToString(pds.PageCount);
((DataList)e.Item.FindControl("DataList1")).DataSource = pds;
((DataList)e.Item.FindControl("DataList1")).DataKeyField = "anliDisplayImgID";
((DataList)e.Item.FindControl("DataList1")).DataBind();
}
}
{
string ID = Request.QueryString["ID"].ToString();
SqlConnection con1 = DC.getCon();
int curpage = Convert.ToInt32(((Label)e.Item.FindControl("labPage")).Text);
PagedDataSource pds = new PagedDataSource();
string strSql1 = "select * from anliDisplayImg where anliDisplayID='" + ID + "' order by anliDisplayImgDate desc ";
SqlDataAdapter sda1 = new SqlDataAdapter();
sda1.SelectCommand = new SqlCommand(strSql1, con1);
DataSet ds1 = new DataSet();
sda1.Fill(ds1, "fill1");
pds.DataSource = ds1.Tables["fill1"].DefaultView;
pds.AllowPaging = true; pds.PageSize = 4; pds.CurrentPageIndex = curpage - 1; //this.GridView1.DataKeyNames = new string[] { "renID" };
((LinkButton)e.Item.FindControl("lnkbtnUp")).Enabled = true;
((LinkButton)e.Item.FindControl("lnkbtnNext")).Enabled = true;
((LinkButton)e.Item.FindControl("lnkbtnBack")).Enabled = true;
((LinkButton)e.Item.FindControl("lnkbtnOne")).Enabled = true;
if (curpage == 1)
{
((LinkButton)e.Item.FindControl("lnkbtnOne")).Enabled = false;
((LinkButton)e.Item.FindControl("lnkbtnUp")).Enabled = false;
}
if (curpage == pds.PageCount)
{
((LinkButton)e.Item.FindControl("lnkbtnNext")).Enabled = false;
((LinkButton)e.Item.FindControl("lnkbtnBack")).Enabled = false;
}
((Label)e.Item.FindControl("labBackPage")).Text = Convert.ToString(pds.PageCount);
((DataList)e.Item.FindControl("DataList1")).DataSource = pds;
((DataList)e.Item.FindControl("DataList1")).DataKeyField = "anliDisplayImgID";
((DataList)e.Item.FindControl("DataList1")).DataBind();
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询