首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

求教老有关问题,gridview分页有关问题

2013-02-18 
求教老问题,gridview分页问题我个人做的一个girdview手动分页显示是这样的但是要求是做一个全功能的分页,

求教老问题,gridview分页问题
我个人做的一个girdview手动分页显示是这样的
求教老有关问题,gridview分页有关问题
但是要求是做一个全功能的分页,最好是
求教老有关问题,gridview分页有关问题

觉得添加12345之类的我不会,因为gridview自动的分页就是这样。特来求教。最好有代码。我是个新手做的比较简单,最好有代码。谢谢了~~ gridview分页
[解决办法]
http://www.cnblogs.com/studyzy/archive/2008/07/30/1256877.html
[解决办法]
 
具体的就不写了就写下分页
<PagerTemplate>
                            <div>
                                <asp:LinkButton ID="cmdFirstPage" runat="server" CommandName="Page" CommandArgument="First"
                                    Enabled="<%# ((GridView)Container.Parent.Parent).PageIndex!=0 %>">首页</asp:LinkButton>
                                <asp:LinkButton ID="cmdPreview" runat="server" CommandArgument="Prev" CommandName="Page"
                                    Enabled="<%# ((GridView)Container.Parent.Parent).PageIndex!=0 %>">前页</asp:LinkButton>
                                <asp:LinkButton ID="cmdNext" runat="server" CommandName="Page" CommandArgument="Next"
                                    Enabled="<%# ((GridView)Container.Parent.Parent).PageIndex!=((GridView)Container.Parent.Parent).PageCount-1 %>">后页</asp:LinkButton>
                                <asp:LinkButton ID="cmdLastPage" runat="server" CommandArgument="Last" CommandName="Page"
                                    Enabled="<%# ((GridView)Container.Parent.Parent).PageIndex!=((GridView)Container.Parent.Parent).PageCount-1 %>">尾页</asp:LinkButton>
                                第<asp:Label ID="lblcurPage" runat="server" Text='<%# ((GridView)Container.Parent.Parent).PageIndex+1      %>'></asp:Label>页/共<asp:Label
                                    ID="lblPageCount" runat="server" Text='<%# ((GridView)Container.Parent.Parent).PageCount %>'></asp:Label>页


                                <asp:TextBox ID="txtNewPageIndex" runat="server" Text=' <%# ((GridView)Container.Parent.Parent).PageIndex + 1  %>'
                                    Width="20px" />
                                <asp:LinkButton ID="btnGo" runat="server" CausesValidation="False" CommandArgument="-1"
                                    CommandName="Page" Text="转" />
                            </div>
                        </PagerTemplate>
后台

 protected void gvNews_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        GridView theGrid = sender as GridView;  // refer to the GridView 
        int newPageIndex = 0;
        if (-2 == e.NewPageIndex)
        {
            TextBox txtNewPageIndex = null;
            GridViewRow pagerRow = theGrid.BottomPagerRow;

            if (null != pagerRow)
            {
                txtNewPageIndex = pagerRow.FindControl("txtNewPageIndex") as TextBox;
            }
            if (null != txtNewPageIndex)
            {
                newPageIndex = int.Parse(txtNewPageIndex.Text) - 1;
            }
        }
        else
        {
            newPageIndex = e.NewPageIndex;
        }

        newPageIndex = newPageIndex < 0 ? 0 : newPageIndex;
        newPageIndex = newPageIndex >= theGrid.PageCount ? theGrid.PageCount - 1 : newPageIndex;
        gv1.PageIndex = newPageIndex;//gv1是你前台要分页的Gridview的id



        GridBind();//就是调用你的查询语句不可省略
    }

热点排行