Wednesday, December 7, 2022

Rownumber in grid with paging ASp.Net C#

  <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" OnRowCancelingEdit="GridView1_RowCancelingEdit" OnRowEditing="GridView1_RowEditing" OnRowUpdating="GridView1_RowUpdating" DataKeyNames="ID,MainID" OnRowDataBound="GridView1_RowDataBound" CssClass="table table-bordered table-responsive" AllowPaging="True" AllowCustomPaging="true" OnPageIndexChanging="GridView1_PageIndexChanging" PageSize="20" FirstPageText="First" PreviousPageText="Previous" NextPageText="Next" LastPageText="Last" AllowSorting="True" OnRowDeleting="GridView1_RowDeleting" OnInit="GridView1_Init" OnRowCommand="GridView1_RowCommand" OnSelectedIndexChanged="OnSelectedIndexChanged">

        <Columns>

            <asp:TemplateField>

                <ItemTemplate>

                    <%# (Container.DataItemIndex + 1) + (GridView1.PageIndex * 20)%>

                    <%--<asp:Label runat="server" ID="lblRownumber" Text='<%# Bind("Rownumber") %>'></asp:Label>--%>

                </ItemTemplate>


Note: This is for 20 record per page

No comments:

Post a Comment