日期:2014-05-17  浏览次数:20455 次

关于GridView分页跳转的问题
GridView分页跳转到几页的功能不能实现。下面代码中txtNewPageIndex的值取得不对。

ASPX 代码:
HTML code

            <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" OnPageIndexChanging="GridView1_PageIndexChanging"
                OnPageIndexChanged="GridView1_PageIndexChanged" AllowPaging="true" PageSize="20"
                Height="117px" Width="800">
                <FooterStyle BackColor="#FFFFFF" Font-Bold="True" ForeColor="White" />
                <Columns>
                    <asp:TemplateField HeaderText="ID" ItemStyle-Width="50px">
                        <ItemTemplate>
                            <asp:Label ID="Labelid" runat="server" Text='<%# Bind("id") %>'></asp:Label>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="IP" ItemStyle-Width="250px">
                        <ItemTemplate>
                            <asp:Label ID="Labelip" runat="server" Text='<%# Eval("ip")+" / "+IPtoText(Eval("ip").ToString()) %>'></asp:Label>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="类型" ItemStyle-Width="220px">
                        <ItemTemplate>
                            <asp:Label ID="Labeltypeid" runat="server" Text='<%# typeidtotext(Eval("typeid").ToString()) %>'></asp:Label>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="操作" ItemStyle-Width="100px">
                        <ItemTemplate>
                            <!--<a style="color: #000;" href="javascript:Update(<%# Eval("id") %>)">修改</a>-->
                            <a style="color: #000;" href="EditLink.aspx?id=(<%# Eval("id") %>)">修改</a> <span
                                onclick="return window.confirm('你真要删除所选项?')"><a href="dellink.aspx?id=<%# Eval("id") %>"
                                    style="color: Black;">删除</a></span>
                        </ItemTemplate>
                    </asp:TemplateField>
                </Columns>
                <RowStyle BackColor="#eef2ff" ForeColor="#333333" />
                <SelectedRowStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="Navy" />
                <PagerStyle BackColor="#7D9AFF" ForeColor="#333333" HorizontalAlign="Center" />
                <HeaderStyle BackColor="#7D9AFF" Font-Bold="True" ForeColor="White" Height="30" />
                <AlternatingRowStyle BackColor="White" />
                <PagerTemplate>
                    第<asp:Label ID="lblPageIndex" runat="server" Text='<%# ((GridView)Container.Parent.Parent).PageIndex + 1 %>' />页
                    共/<asp:Label ID="lblPageCount" runat="server" Text='<%# ((GridView)Container.Parent.Parent).PageCount %>' />页
                    <asp:LinkButton ID="lbnFirst" runat="Server" Text="首页" Enabled='<%# ((GridView)Container.NamingConta