Articles → ASP .NET GRIDVIEW → Page Numbers Not Visible In Gridview Paging In Asp.Net
Page Numbers Not Visible In Gridview Paging In Asp.Net
- Add 2 properties in gridview i.e. AllowPaging="true" and PageSize="2".
<asp:GridView ID="gvEmployeeList" runat="server" AutoGenerateColumns="false"
PageSize="2" AllowPaging="true"/>
- On the page load I had bind the datasource with the grid.
DataSet ds = new DataSet();
ds.ReadXml(Server.MapPath("Data.xml"));
gvEmployeeList.DataSource = ds.Tables[0];
gvEmployeeList.DataBind();
- Create a pageindex changing event.
protected void gvEmployeeList_PageIndexChanging(object sender, GridViewPageEventArgs e) {
gvEmployeeList.PageIndex = e.NewPageIndex;
BindData();
}
- Hide the first cell of the gridview in row databound
protected void gvEmployeeList_RowDataBound(object sender, GridViewRowEventArgs e) {
e.Row.Cells[0].Visible = false;
}
Click to Enlarge
Reason And Resolution
e.Row.Cells[0].Visible = false;
if (e.Row.RowType != DataControlRowType.Pager)
e.Row.Cells[0].Visible = false;