Articles → ASP .NET GRIDVIEW → Page Numbers Not Visible In Gridview Paging In Asp.Net

Page Numbers Not Visible In Gridview Paging In Asp.Net









  1. Add 2 properties in gridview i.e. AllowPaging="true" and PageSize="2".
  2. <asp:GridView ID="gvEmployeeList" runat="server" AutoGenerateColumns="false" 
    PageSize="2" AllowPaging="true"/>


  3. On the page load I had bind the datasource with the grid.
  4. DataSet ds = new DataSet();
    ds.ReadXml(Server.MapPath("Data.xml"));
    gvEmployeeList.DataSource = ds.Tables[0];
    gvEmployeeList.DataBind();


  5. Create a pageindex changing event.
  6. protected void gvEmployeeList_PageIndexChanging(object sender, GridViewPageEventArgs e) {
      gvEmployeeList.PageIndex = e.NewPageIndex;
      BindData();
    }


  7. Hide the first cell of the gridview in row databound
  8. protected void gvEmployeeList_RowDataBound(object sender, GridViewRowEventArgs e) {
      e.Row.Cells[0].Visible = false;
    }




Picture showing the datagrid without the page numbers in asp.net
Click to Enlarge




Reason And Resolution




e.Row.Cells[0].Visible = false;






if (e.Row.RowType != DataControlRowType.Pager)        
    e.Row.Cells[0].Visible = false;



Posted By  -  Karan Gupta
 
Posted On  -  Tuesday, July 5, 2011

Query/Feedback


Your Email Id
 
Subject
 
Query/FeedbackCharacters remaining 250