下面这段代码放在gridview分页模板里 也就是PagerTemplate这个里
<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 GridView1_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;
本内容试读结束,登录后可阅读更多
下载后可阅读完整内容,剩余1页未读,立即下载