My markup is:
<asp:GridView ID="grvGroup" runat="server" AutoGenerateColumns="False" Width="100%" AllowPaging="True"
PageSize="10" CssClass="mydatagrid"
OnRowDataBound="grvGroup_RowDataBound" OnRowDeleting="grvGroup_RowDeleting" OnRowCommand="grvGroup_RowCommand"
DataKeyNames="No" OnPageIndexChanging="grvGroup_PageIndexChanging" PagerStyle-HorizontalAlign="Center"
PagerSettings-Mode="NumericFirstLast"
PagerSettings-Visible="True">
<Columns>
<asp:ButtonField CommandName="Select" ButtonType="Button" ControlStyle-CssClass="Edit_btn" HeaderStyle-HorizontalAlign="Left" ItemStyle-HorizontalAlign="Left" ItemStyle-Width="5px" HeaderStyle-Width="5px" />
<asp:BoundField HeaderText="Sl.No." ItemStyle-Width="5px" HeaderStyle-Width="5px" DataField="No" HeaderStyle-HorizontalAlign="Left" ItemStyle-HorizontalAlign="Left" />
<asp:BoundField HeaderText="InvoiceNumber" ItemStyle-Width="100px" HeaderStyle-Width="100px" DataField="InvoiceNumber" HeaderStyle-HorizontalAlign="Left" ItemStyle-HorizontalAlign="Left" />
<asp:BoundField HeaderText="Vou Date" ItemStyle-Width="80px" HeaderStyle-Width="80px" DataField="CDate" HeaderStyle-HorizontalAlign="Left" DataFormatString="{0:dd/MM/yyyy}" HtmlEncode="False" ItemStyle-HorizontalAlign="Left" />
<asp:BoundField HeaderText="BankName" ItemStyle-Width="130px" HeaderStyle-Width="130px" DataField="BankName" HeaderStyle-HorizontalAlign="Left" ItemStyle-HorizontalAlign="Left" />
</Columns>
<EmptyDataRowStyle HorizontalAlign="Center" />
<HeaderStyle CssClass="header" />
<PagerStyle CssClass="pager" />
<RowStyle CssClass="rows" />
<AlternatingRowStyle CssClass="row-alt" />
</asp:GridView>
This is my code behind file:
private void BindData(long refNo = 0, int pageIndex = 0)
{
try
{
int pageSize = grvGroup.PageSize; // Get the page size
DataSet Data = CommonClass.DSWriteToTable(
_GetBank( refNo, pageIndex, pageSize)
);
if (Data != null && Data .Tables.Count > 1)
{
DataTable dt = Data .Tables[1];
if (dt.Rows.Count > 0)
{
grvGroup.AllowPaging = true;
grvGroup.PageSize = 10;
grvGroup.Visible = true;
grvGroup.PageIndex = pageIndex;
grvGroup.DataSource = dt;
grvGroup.DataBind();
}
else
{
grvGroup.Visible = false;
}
if (Data .Tables.Count > 2 && Data .Tables[2].Rows.Count > 0)
{
int totalRows = Convert.ToInt32(Data .Tables[2].Rows[0]["Counts"]);
int totalPages = (int)Math.Ceiling((double)totalRows / pageSize);
ViewState["TotalPages"] = totalPages;
}
}
}
catch (Exception ex)
{
}
}
While if the data set having more than 10 rows, it is showing row numbers under the grid if we use pagination set it is not showing any row number so the pagination is not happening


Data.Tables[1]will only contain 10 rows since you send thepageSizeandpageIndexparameter toDSWriteToTable. If so there is nothing to page for the gridview, that only works if the amount of rows bound to it is greater than PageSize.