我现在用的是GridView的自动分页(页码)
显示为
...1 2 3 4 5...
这种形式
现在我想把...改为 下十页 
再加上一页,下一页。
不知道才能!

解决方案 »

  1.   

    自己添加按钮来实现,不使用GridView本身的功能。
      

  2.   

    自己写代码实现,不用自带的分页.
    也可以用aspnetpager控件,最新版本发布没几天.很不错的分页控件,免费开源的
      

  3.   

     
                    <asp:GridView ID="GridView2" runat="server" Height="138px" Style="left: 55px; position: absolute;
                    top: 240px" Width="603px" AutoGenerateColumns="False" OnRowCreated="GridView1_RowCreated" OnRowDataBound="GridView2_RowDataBound" AllowPaging="True" PageSize="2" CellPadding="4" ForeColor="#333333" GridLines="None">
                        <Columns>
                        <asp:TemplateField>
                         <HeaderTemplate>
                         <asp:CheckBox ID="CheckBox2" runat="server" Text="全选"  OnCheckedChanged="CheckBox2_CheckedChanged" AutoPostBack="true" />           
                         </HeaderTemplate>
                        <ItemTemplate>
                         <asp:CheckBox ID="Chkitem" runat="server" Text='<%# DataBinder.Eval(Container.DataItem,"Id") %>' />
                        </ItemTemplate>
                        </asp:TemplateField>
                            <asp:BoundField DataField="authorName" HeaderText="作者" />
                            <asp:BoundField DataField="City" HeaderText="城市" />
                        </Columns>
                        <PagerSettings Visible="False" />
                        <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                        <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
                        <EditRowStyle BackColor="#999999" />
                        <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
                        <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
                        <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                        <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
                    </asp:GridView>
                &nbsp;
                <asp:Panel ID="Panel1" runat="server" BackColor="#FF80FF" Height="34px" Style="left: 55px;
                    position: absolute; top: 379px" Width="609px">
                    <asp:Button ID="cmdFirst" runat="server" CommandArgument="first" CommandName="page"
                        OnClick="cmdFirst_Click" Style="left: 10px; position: absolute; top: 4px" Text="首页"
                        Width="57px" Height="25px" />
                    <asp:Button ID="cmdPrevious" runat="server" CommandArgument="previous" CommandName="page"
                        OnClick="cmdPrevious_Click" Style="left: 67px; position: absolute; top: 5px"
                        Text="上一页" />
                    <asp:Button ID="cmdNext" runat="server" CommandArgument="next" CommandName="page"
                        OnClick="cmdNext_Click" Style="left: 127px; position: absolute; top: 5px" Text="下一页" />
                    <asp:Button ID="cmdLast" runat="server" CommandArgument="last" CommandName="page"
                        OnClick="cmdLast_Click" Style="left: 187px; position: absolute; top: 5px" Text="尾页"
                        Width="58px" />
                    <asp:Label ID="Label1" runat="server" Style="left: 251px; position: absolute; top: 8px"
                        Text="Label" Width="61px"></asp:Label>
                    &nbsp;&nbsp;
                    <asp:Button ID="cmdTrans" runat="server" Style="left: 466px; position: absolute; top: 5px"
                        Text="go" OnClick="cmdTrans_Click"  />
                    <asp:Label ID="Label2" runat="server" Style="left: 404px; position: absolute; top: 8px"
                        Text="第" Width="22px"></asp:Label>
                    &nbsp;
                    <asp:TextBox ID="txtNumber" runat="server" onkeypress="return   event.keyCode>=48&&event.keyCode<=57||event.keyCode==46"  onpaste="return !clipboardData.getData('text').match(/\D/)"   style="ime-mode:Disabled; left: 425px; position: absolute; top: 5px;"   ondragenter="return  false" Width="29px"></asp:TextBox>
                    <asp:Label ID="Label4" runat="server" Style="left: 316px; position: absolute; top: 8px"
                        Text="Label"></asp:Label>
                    <asp:Label ID="Label3" runat="server" Style="left: 349px; position: absolute; top: 8px"
                        Text="Label"></asp:Label>
                </asp:Panel>
            </div>
      

  4.   

    private void bind2()
        {
            string sqlStr = "select * from authors order by id";
            db myDb = new db();
            GridView2.DataSource = myDb.dt(sqlStr);
            GridView2.AllowPaging = true;
            GridView2.PageSize = 2;
            GridView2.DataBind();
            Label1.Text = "共" + GridView2.PageCount + "页" +" / ";
            Label4.Text =Convert.ToString(GridView2.PageIndex + 1);
            Label3.Text = " 页";
            if (GridView2.PageIndex == 0)
            {
                cmdFirst.Enabled = false;
                cmdPrevious.Enabled = false;
            }
            else
            {
                cmdFirst.Enabled = true;
                cmdPrevious.Enabled = true;
            }        if (GridView2.PageIndex == GridView2.PageCount - 1)
            {
                cmdNext.Enabled = false;
                cmdLast.Enabled = false;
            }
            else
            {
                cmdNext.Enabled = true;
                cmdLast.Enabled = true;
            }
        }
      

  5.   

       protected void cmdFirst_Click(object sender, EventArgs e)
        {
            GridView2.PageIndex = 0;
            bind2();
        }
        protected void cmdPrevious_Click(object sender, EventArgs e)
        {
            GridView2.PageIndex = GridView2.PageIndex - 1;
            bind2();
        }    protected void cmdNext_Click(object sender, EventArgs e)
        {
           GridView2.PageIndex = GridView2.PageIndex + 1;
           bind2();
        }
        protected void cmdLast_Click(object sender, EventArgs e)
        {
            GridView2.PageIndex = GridView2.PageCount - 1;
            bind2();
        }
      

  6.   

    自己写一个不用Gridview的也行.用GridView的分页功能,但自己定义分页的按钮也行.用PageIndex