gridView后台代码绑定,同一个gridview绑定了多次,也就是有不同的数据,怎么分页呀 急急急
分页的方法我这有,但是点击上下也的时候会在重新绑定一下数据,里面的每个查询方法都是一个数据源,怎么实现分页有正解的话绝对给高分...
分页的方法我这有,但是点击上下也的时候会在重新绑定一下数据,里面的每个查询方法都是一个数据源,怎么实现分页 有正解的话绝对给高分
展开
展开全部
public void BindGridView()
{
hy.BLL.Dorm bll = new hy.BLL.Dorm();
DataSet ds = bll.GetList(str);
GridView1.DataKeyNames = new string[] { "id" };
GridView1.DataSource = ds;//或者 可为 你的数据源
GridView1.DataBind();
this.ddlCurrentPage.Items.Clear();
for (int i = 1; i <= this.GridView1.PageCount; i++)
{
this.ddlCurrentPage.Items.Add(i.ToString());
}
if (this.GridView1.PageIndex > 0)
{
this.ddlCurrentPage.SelectedIndex = this.GridView1.PageIndex;
}
}
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
this.GridView1.PageIndex = this.ddlCurrentPage.SelectedIndex;
BindGridView();
}
protected void lnkbtnFrist_Click(object sender, EventArgs e)
{
this.GridView1.PageIndex = 0;
BindGridView();
}
protected void lnkbtnPre_Click(object sender, EventArgs e)
{
if (this.GridView1.PageIndex > 0)
{
this.GridView1.PageIndex = this.GridView1.PageIndex - 1;
BindGridView();
}
}
protected void lnkbtnNext_Click(object sender, EventArgs e)
{
if (this.GridView1.PageIndex < this.GridView1.PageCount)
{
this.GridView1.PageIndex = this.GridView1.PageIndex + 1;
BindGridView();
}
}
protected void lnkbtnLast_Click(object sender, EventArgs e)
{
this.GridView1.PageIndex = this.GridView1.PageCount;
BindGridView();
}
{
hy.BLL.Dorm bll = new hy.BLL.Dorm();
DataSet ds = bll.GetList(str);
GridView1.DataKeyNames = new string[] { "id" };
GridView1.DataSource = ds;//或者 可为 你的数据源
GridView1.DataBind();
this.ddlCurrentPage.Items.Clear();
for (int i = 1; i <= this.GridView1.PageCount; i++)
{
this.ddlCurrentPage.Items.Add(i.ToString());
}
if (this.GridView1.PageIndex > 0)
{
this.ddlCurrentPage.SelectedIndex = this.GridView1.PageIndex;
}
}
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
this.GridView1.PageIndex = this.ddlCurrentPage.SelectedIndex;
BindGridView();
}
protected void lnkbtnFrist_Click(object sender, EventArgs e)
{
this.GridView1.PageIndex = 0;
BindGridView();
}
protected void lnkbtnPre_Click(object sender, EventArgs e)
{
if (this.GridView1.PageIndex > 0)
{
this.GridView1.PageIndex = this.GridView1.PageIndex - 1;
BindGridView();
}
}
protected void lnkbtnNext_Click(object sender, EventArgs e)
{
if (this.GridView1.PageIndex < this.GridView1.PageCount)
{
this.GridView1.PageIndex = this.GridView1.PageIndex + 1;
BindGridView();
}
}
protected void lnkbtnLast_Click(object sender, EventArgs e)
{
this.GridView1.PageIndex = this.GridView1.PageCount;
BindGridView();
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
我觉得你应该去写存储过程!!!
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询