Saturday, 22 March 2014

Displaying total and current page in gridview footer

Most of the time User got stuck that how pages there in grid and in which page he is current; The best solution for it that to show the user for his\her current page location in grid view. Just displaying the current page of grid and total number of pages in the grid;

  Code Snippet

@C# Code if you see the code the current page and number of page in grid will display only at the footer of the page from

 e.Row.RowType == DataControlRowType.Footer
 protected void

grdCGGoodsDesc_RowDataBound(object sender, GridViewRowEventArgs e)  
 {         if (e.Row.RowType == DataControlRowType.Footer)      
                 {          
e.Row.Cells[0].Text = "Page <b>" + (grdCGGoodsDesc.PageIndex + 1) + "</b> Of <b>" + grdCGGoodsDesc.PageCount + "</b>";      
}  
}



  @Html Code - Allow the footer on your grid that content will be display only at the footer of the grid ShowFooter="true"

 <FooterStyle Height="20px" BackColor="#9999ff" CssClass="AlternateGridRowStyle" />

  @CSS Code

.AlternateGridRowStyle
{ background-color: #DEDEDE; }


 It will display on your page is like below, you can see the current page and total number of page in grid.

No comments:

Post a Comment

Others

You will like to read it