3个回答
展开全部
你说的第一个datalist是内层的吗,首先查询出有多少条记录,这个会吧;然后确定页面大小和当前页(可以保存在一个label里,让其不可见),设置linkbutton,上一页下一页,给linkbutton设置commandName属性,然后在外层datalist的ItemCommand事件里写翻页if(e.commandname=="linkbutton的commandName")就显示下一页,比如pageIndex+1
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
private void getGoods()
{
string strsql = "select * from table7 order by 流水号 ";
DataTable dt = BaseClass1.ReadTable(strsql);
PagedDataSource objPds = new PagedDataSource();
objPds.DataSource = dt.DefaultView;
objPds.AllowPaging = true;
objPds.PageSize = 8;
int CurPage = Convert.ToInt32(this.LabelPage.Text);
objPds.CurrentPageIndex = CurPage - 1;
if (objPds.CurrentPageIndex < 0)
{
objPds.CurrentPageIndex = 0;
}
if (objPds.PageCount == 1)
{
LinkButtonPrev.Enabled = false;
LinkButtonNext.Enabled = false;
}
else
{
if (CurPage == 1)
{
LinkButtonPrev.Enabled = false;
LinkButtonNext.Enabled = true;
}
if (CurPage == objPds.PageCount)
{
LinkButtonPrev.Enabled = true;
LinkButtonNext.Enabled = false;
}
}
this.LabelTotalPage.Text = Convert.ToString(objPds.PageCount);
DataList1.DataSource = objPds;
DataList1.DataBind();
}
protected void Button1_Click(object sender, EventArgs e)
{
Response.Redirect("products.aspx");
}
protected void LinkButtonFirst_Click(object sender, EventArgs e)
{
this.LabelPage.Text = "1";
getGoods();
}
protected void LinkButtonPrev_Click(object sender, EventArgs e)
{
this.LabelPage.Text = Convert.ToString(int.Parse(this.LabelPage.Text) - 1);
getGoods();
}
protected void LinkButtonNext_Click(object sender, EventArgs e)
{
this.LabelPage.Text = Convert.ToString(int.Parse(this.LabelPage.Text) + 1);
getGoods();
}
protected void LinkButtonLast_Click(object sender, EventArgs e)
{
this.LabelPage.Text = this.LabelTotalPage.Text;
getGoods();
}
protected void DataList1_SelectedIndexChanged1(object sender, EventArgs e)
{
} 赞同0| 评论
{
string strsql = "select * from table7 order by 流水号 ";
DataTable dt = BaseClass1.ReadTable(strsql);
PagedDataSource objPds = new PagedDataSource();
objPds.DataSource = dt.DefaultView;
objPds.AllowPaging = true;
objPds.PageSize = 8;
int CurPage = Convert.ToInt32(this.LabelPage.Text);
objPds.CurrentPageIndex = CurPage - 1;
if (objPds.CurrentPageIndex < 0)
{
objPds.CurrentPageIndex = 0;
}
if (objPds.PageCount == 1)
{
LinkButtonPrev.Enabled = false;
LinkButtonNext.Enabled = false;
}
else
{
if (CurPage == 1)
{
LinkButtonPrev.Enabled = false;
LinkButtonNext.Enabled = true;
}
if (CurPage == objPds.PageCount)
{
LinkButtonPrev.Enabled = true;
LinkButtonNext.Enabled = false;
}
}
this.LabelTotalPage.Text = Convert.ToString(objPds.PageCount);
DataList1.DataSource = objPds;
DataList1.DataBind();
}
protected void Button1_Click(object sender, EventArgs e)
{
Response.Redirect("products.aspx");
}
protected void LinkButtonFirst_Click(object sender, EventArgs e)
{
this.LabelPage.Text = "1";
getGoods();
}
protected void LinkButtonPrev_Click(object sender, EventArgs e)
{
this.LabelPage.Text = Convert.ToString(int.Parse(this.LabelPage.Text) - 1);
getGoods();
}
protected void LinkButtonNext_Click(object sender, EventArgs e)
{
this.LabelPage.Text = Convert.ToString(int.Parse(this.LabelPage.Text) + 1);
getGoods();
}
protected void LinkButtonLast_Click(object sender, EventArgs e)
{
this.LabelPage.Text = this.LabelTotalPage.Text;
getGoods();
}
protected void DataList1_SelectedIndexChanged1(object sender, EventArgs e)
{
} 赞同0| 评论
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
private void getGoods()
{
string strsql = "select * from table7 order by 流水号 ";
DataTable dt = BaseClass1.ReadTable(strsql);
PagedDataSource objPds = new PagedDataSource();
objPds.DataSource = dt.DefaultView;
objPds.AllowPaging = true;
objPds.PageSize = 8;
int CurPage = Convert.ToInt32(this.LabelPage.Text);
objPds.CurrentPageIndex = CurPage - 1;
if (objPds.CurrentPageIndex < 0)
{
objPds.CurrentPageIndex = 0;
}
if (objPds.PageCount == 1)
{
LinkButtonPrev.Enabled = false;
LinkButtonNext.Enabled = false;
}
else
{
if (CurPage == 1)
{
LinkButtonPrev.Enabled = false;
LinkButtonNext.Enabled = true;
}
if (CurPage == objPds.PageCount)
{
LinkButtonPrev.Enabled = true;
LinkButtonNext.Enabled = false;
}
}
this.LabelTotalPage.Text = Convert.ToString(objPds.PageCount);
DataList1.DataSource = objPds;
DataList1.DataBind();
}
protected void Button1_Click(object sender, EventArgs e)
{
Response.Redirect("products.aspx");
}
protected void LinkButtonFirst_Click(object sender, EventArgs e)
{
this.LabelPage.Text = "1";
getGoods();
}
protected void LinkButtonPrev_Click(object sender, EventArgs e)
{
this.LabelPage.Text = Convert.ToString(int.Parse(this.LabelPage.Text) - 1);
getGoods();
}
protected void LinkButtonNext_Click(object sender, EventArgs e)
{
this.LabelPage.Text = Convert.ToString(int.Parse(this.LabelPage.Text) + 1);
getGoods();
}
protected void LinkButtonLast_Click(object sender, EventArgs e)
{
this.LabelPage.Text = this.LabelTotalPage.Text;
getGoods();
}
protected void DataList1_SelectedIndexChanged1(object sender, EventArgs e)
{
}
{
string strsql = "select * from table7 order by 流水号 ";
DataTable dt = BaseClass1.ReadTable(strsql);
PagedDataSource objPds = new PagedDataSource();
objPds.DataSource = dt.DefaultView;
objPds.AllowPaging = true;
objPds.PageSize = 8;
int CurPage = Convert.ToInt32(this.LabelPage.Text);
objPds.CurrentPageIndex = CurPage - 1;
if (objPds.CurrentPageIndex < 0)
{
objPds.CurrentPageIndex = 0;
}
if (objPds.PageCount == 1)
{
LinkButtonPrev.Enabled = false;
LinkButtonNext.Enabled = false;
}
else
{
if (CurPage == 1)
{
LinkButtonPrev.Enabled = false;
LinkButtonNext.Enabled = true;
}
if (CurPage == objPds.PageCount)
{
LinkButtonPrev.Enabled = true;
LinkButtonNext.Enabled = false;
}
}
this.LabelTotalPage.Text = Convert.ToString(objPds.PageCount);
DataList1.DataSource = objPds;
DataList1.DataBind();
}
protected void Button1_Click(object sender, EventArgs e)
{
Response.Redirect("products.aspx");
}
protected void LinkButtonFirst_Click(object sender, EventArgs e)
{
this.LabelPage.Text = "1";
getGoods();
}
protected void LinkButtonPrev_Click(object sender, EventArgs e)
{
this.LabelPage.Text = Convert.ToString(int.Parse(this.LabelPage.Text) - 1);
getGoods();
}
protected void LinkButtonNext_Click(object sender, EventArgs e)
{
this.LabelPage.Text = Convert.ToString(int.Parse(this.LabelPage.Text) + 1);
getGoods();
}
protected void LinkButtonLast_Click(object sender, EventArgs e)
{
this.LabelPage.Text = this.LabelTotalPage.Text;
getGoods();
}
protected void DataList1_SelectedIndexChanged1(object sender, EventArgs e)
{
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询