<PagerTemplate>
<asp:LinkButton ID="lbFirst" runat="server" CausesValidation="False" CommandArgument="First"
CommandName="Page">首页 </asp:LinkButton>
<asp:LinkButton ID="lbPrev" runat="server" CausesValidation="False" CommandArgument="Prev"
CommandName="Page">上一页 </asp:LinkButton>
<asp:LinkButton ID="lbNext" runat="server" CausesValidation="False" CommandArgument="Next"
CommandName="Page">下一页 </asp:LinkButton>
<asp:LinkButton ID="lbLast" runat="server" CausesValidation="False" CommandArgument="Last"
CommandName="Page">尾页 </asp:LinkButton> 第 <asp:Label ID="Label2"
runat="server" Text=" <%#((GridView)Container.Parent.Parent).PageIndex + 1 %>"> </asp:Label>页
共 <asp:Label ID="Label1" runat="server" Text=" <%# ((GridView)Container.Parent.Parent).PageCount %>"> </asp:Label>页
跳到 <asp:TextBox ID="tbPage" runat="server" Text=" <%# ((GridView)Container.Parent.Parent).PageIndex + 1 %>"
Width="27px"> </asp:TextBox>
<asp:LinkButton ID="lbGO" runat="server" CausesValidation="False" CommandArgument="-1"
CommandName="Page" Text="GO"> </asp:LinkButton>
</PagerTemplate>
分页事件
protected void borrowGridView_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
GridView gvw = (GridView)sender; if (e.NewPageIndex < 0)
{
TextBox pageNum = (TextBox)gvw.BottomPagerRow.FindControl("tbpage"); int Pa = int.Parse(pageNum.Text);
if (Pa <= 0)
gvw.PageIndex = 0;
else
gvw.PageIndex = Pa - 1; }
else
{
gvw.PageIndex = e.NewPageIndex;
} borrowGridView.DataSource = sa.selAssertBorrow();
borrowGridView.DataBind();
}
首页 上一页 下一页 尾页 第?页 共?页 跳到(文本框)页GO
前台和后台代码都在上面,帮忙修改一下代码! 要实现点GO后要获取文本框里面的值,根据值跳转到GridView中指定的页! 帮忙`````````` 在源代码上修改!
<asp:LinkButton ID="lbFirst" runat="server" CausesValidation="False" CommandArgument="First"
CommandName="Page">首页 </asp:LinkButton>
<asp:LinkButton ID="lbPrev" runat="server" CausesValidation="False" CommandArgument="Prev"
CommandName="Page">上一页 </asp:LinkButton>
<asp:LinkButton ID="lbNext" runat="server" CausesValidation="False" CommandArgument="Next"
CommandName="Page">下一页 </asp:LinkButton>
<asp:LinkButton ID="lbLast" runat="server" CausesValidation="False" CommandArgument="Last"
CommandName="Page">尾页 </asp:LinkButton> 第 <asp:Label ID="Label2"
runat="server" Text=" <%#((GridView)Container.Parent.Parent).PageIndex + 1 %>"> </asp:Label>页
共 <asp:Label ID="Label1" runat="server" Text=" <%# ((GridView)Container.Parent.Parent).PageCount %>"> </asp:Label>页
跳到 <asp:TextBox ID="tbPage" runat="server" Text=" <%# ((GridView)Container.Parent.Parent).PageIndex + 1 %>"
Width="27px"> </asp:TextBox>
<asp:LinkButton ID="lbGO" runat="server" CausesValidation="False" CommandArgument="-1"
CommandName="Page" Text="GO"> </asp:LinkButton>
</PagerTemplate>
分页事件
protected void borrowGridView_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
GridView gvw = (GridView)sender; if (e.NewPageIndex < 0)
{
TextBox pageNum = (TextBox)gvw.BottomPagerRow.FindControl("tbpage"); int Pa = int.Parse(pageNum.Text);
if (Pa <= 0)
gvw.PageIndex = 0;
else
gvw.PageIndex = Pa - 1; }
else
{
gvw.PageIndex = e.NewPageIndex;
} borrowGridView.DataSource = sa.selAssertBorrow();
borrowGridView.DataBind();
}
首页 上一页 下一页 尾页 第?页 共?页 跳到(文本框)页GO
前台和后台代码都在上面,帮忙修改一下代码! 要实现点GO后要获取文本框里面的值,根据值跳转到GridView中指定的页! 帮忙`````````` 在源代码上修改!
解决方案 »
- 求多表多条件分页存储过程(带@group变量)
- 如何在.aspx页面里 给TextBox添加JS事件
- 两个DateTime类型的值相减之后取得时间差(以月份形式!)?
- 问一个csdn blog的使用小问题
- 用VS 2010遇到的问题
- ASP.Net中怎么给母版页设置主题
- 简单问题,如何获取调用该页面的上一页面的URI
- 新人求助!IE无法打开localhost,火狐正常显示iis页面
- 我的DADEGRID控件显示了很多数据,我现在想让它一页一页的显示数据,所以我把它的属性设置了一下?但是我不记得在哪个事件里写代码了?
- 多选的Listbox数据绑定后的读取多选项的问题?
- 导出数据到execl如何设置sheet的名称,向大虾求助
- asp.net DropDownList
TextBox pageNum = (TextBox)pagerRow.Cells[0].FindControl("tbpage");
<asp:LinkButton ID="lbFirst" runat="server" CausesValidation="False" CommandArgument="First" Enabled="false"
CommandName="Page">首页 </asp:LinkButton>
<asp:LinkButton ID="lbPrev" runat="server" CausesValidation="False" CommandArgument="Prev" Enabled="false"
CommandName="Page">上一页 </asp:LinkButton>
<asp:LinkButton ID="lbNext" runat="server" CausesValidation="False" CommandArgument="Next"
CommandName="Page">下一页 </asp:LinkButton>
<asp:LinkButton ID="lbLast" runat="server" CausesValidation="False" CommandArgument="Last"
CommandName="Page">尾页 </asp:LinkButton> 第 <asp:Label ID="Label2"
runat="server" Text=" <%#((GridView)Container.Parent.Parent).PageIndex + 1 %>"> </asp:Label>页
共 <asp:Label ID="Label1" runat="server" Text=" <%# ((GridView)Container.Parent.Parent).PageCount %>"> </asp:Label>页
跳到 <asp:TextBox ID="tbPage" runat="server" Text=" <%# ((GridView)Container.Parent.Parent).PageIndex + 1 %>"
Width="27px"> </asp:TextBox>
<asp:LinkButton ID="lbGO" runat="server" CausesValidation="False" CommandArgument="-1"
CommandName="Pageindex" Text="GO"> </asp:LinkButton>
</PagerTemplate>
CS代码:
protected void GridView1_RowCommand1(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "Pageindex")
{
TextBox tb=GridView1.BottomPagerRow.FindControl("tbPage") as TextBox;
int pageindex = Convert.ToInt32(tb.Text);
GridView1.PageIndex = pageindex-1;
GridView1.DataSource = (DataView)Session["temp"];
GridView1.DataBind();
}
} protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{ GridView1.PageSize = 4;
GridView1.PageIndex = e.NewPageIndex;
GridView1.DataSource=(DataView)Session["temp"];
GridView1.DataBind();
}这样就可以了
<asp:LinkButton ID="lbFirst" runat="server" CausesValidation="False" CommandArgument="First" Enabled="false"
CommandName="Page">首页 </asp:LinkButton>
<asp:LinkButton ID="lbPrev" runat="server" CausesValidation="False" CommandArgument="Prev" Enabled="false"
CommandName="Page">上一页 </asp:LinkButton>
<asp:LinkButton ID="lbNext" runat="server" CausesValidation="False" CommandArgument="Next"
CommandName="Page">下一页 </asp:LinkButton>
<asp:LinkButton ID="lbLast" runat="server" CausesValidation="False" CommandArgument="Last"
CommandName="Page">尾页 </asp:LinkButton> 第 <asp:Label ID="Label2"
runat="server" Text=" <%#((GridView)Container.Parent.Parent).PageIndex + 1 %>"> </asp:Label>页
共 <asp:Label ID="Label1" runat="server" Text=" <%# ((GridView)Container.Parent.Parent).PageCount %>"> </asp:Label>页
跳到 <asp:TextBox ID="tbPage" runat="server" Text=" <%# ((GridView)Container.Parent.Parent).PageIndex + 1 %>"
Width="27px"> </asp:TextBox>
<asp:LinkButton ID="lbGO" runat="server" CausesValidation="False" CommandArgument="-1"
CommandName="Pageindex" Text="GO"> </asp:LinkButton>
</PagerTemplate>
CS代码:
protected void GridView1_RowCommand1(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "Pageindex")
{
TextBox tb=GridView1.BottomPagerRow.FindControl("tbPage") as TextBox;
int pageindex = Convert.ToInt32(tb.Text);
GridView1.PageIndex = pageindex-1;
GridView1.DataSource = (DataView)Session["temp"];
GridView1.DataBind();
}
} protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{ GridView1.PageSize = 4;
GridView1.PageIndex = e.NewPageIndex;
GridView1.DataSource=(DataView)Session["temp"];
GridView1.DataBind();
}这样就可以了
CommandName="Pageindex" Text="GO"> </asp:LinkButton>
这里的CommandName="Pageindex"
Session里存的是数据
CommandName="Page" Text="GO" OnClick="GoIndex"> </asp:LinkButton>//添加对lbGO单击事件
protected void GoIndex(object sender, EventArgs e)
{
GridViewRow pagerRow = GridView1.BottomPagerRow;
TextBox pageNum = pagerRow.Cells[0].FindControl("tbpage") as TextBox;
if(pageNum.Text!=null)
GridView1.PageIndex = Convert.ToInt32(pageNum.Text)-1;
}protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
if(e.NewPageIndex>=0&&e.NewPageIndex<GridView1.PageCount)
GridView1.PageIndex = e.NewPageIndex;
gview_bind(); //绑定数据源
}这样就可以了