Gridview中分页的详细信息

时间:2014-11-25 06:31:16

标签: asp.net search gridview

我有一个gridview,其数据来自数据库。我还想在gridview中显示分页。我想在图像中提到如下所述的分页。

Image。由于我不知道从哪里开始这个,你能告诉我任何有用的链接,以便我可以开始开发它。另请参阅代码供您参考: -

 <asp:GridView ID="grdCSRPageData" runat="server" Width="100%" border="1" Style="border: 1px solid #E5E5E5;" CellPadding="3" AutoGenerateColumns="false" OnDataBound="grdCSRPageData_DataBound" PageSize="5" AllowPaging="true" OnPageIndexChanging="grdCSRPageData_PageIndexChanging" OnRowCommand="grdCSRPageData_RowCommand">
                <AlternatingRowStyle BackColor="#CCCCCC" />
                <Columns>
                    <asp:TemplateField ItemStyle-Width="30">
                        <ItemTemplate>
                            <asp:CheckBox ID="chkSelect" runat="server" />
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:BoundField DataField="page_title" HeaderText="Page Title" ItemStyle-Width="30" />
                    <asp:BoundField DataField="page_description" HeaderText="Page Description" ItemStyle-Width="30" />
                    <asp:BoundField DataField="meta_title" HeaderText="Meta Title" ItemStyle-Width="30" />
                    <asp:BoundField DataField="meta_keywords" HeaderText="Meta Keywords" ItemStyle-Width="30" />
                    <asp:BoundField DataField="meta_description" HeaderText="Meta Description" ItemStyle-Width="30" />
                    <asp:BoundField DataField="Active" HeaderText="Active" ItemStyle-Width="30" />
                    <asp:TemplateField HeaderText="Action" HeaderStyle-Width="15%">
                        <ItemTemplate>
                            <asp:ImageButton ID="btnEdit" runat="server" ImageUrl="~/images/edit.png" Width="15" Height="15" />
                            <asp:ImageButton ID="btnDelete" AlternateText="Delete" ImageUrl="~/images/delete.png" runat="server" Width="15" Height="15" CommandName="DeleteRow" CommandArgument="<%# Eval("Id") %>" OnClientClick="return confirm('Are you sure to delete?');" />
                            </span>
                        </ItemTemplate>
                        <EditItemTemplate>
                            <asp:LinkButton ID="btnUpdate" Text="Update" runat="server" CommandName="Update" />
                            <asp:LinkButton ID="btnCancel" Text="Cancel" runat="server" CommandName="Cancel" />
                        </EditItemTemplate>
                    </asp:TemplateField>
                </Columns>
            </asp:GridView>

现在,我只有这么多的PageIndexChanging代码,如果你需要别的东西让我知道

  protected void grdCSRPageData_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        grdCSRPageData.PageIndex = e.NewPageIndex;
        grdCSRPageData.DataBind();
    }

1 个答案:

答案 0 :(得分:0)

您应该在活动&#39; grdCSRPageData_PageIndexChanging&#39;上编写C#代码。与&#39; grdCSRPageData_DataBound&#39;

相同