Sunday, October 27, 2013

Count total rows of gridview with pagination asp net

For this example
GridView ID: gvStudents
SqlDataSourceID: dsApplications
Event: dsApplications_Selected
protected void dsApplications_Selected(object sender, SqlDataSourceStatusEventArgs e)
{
   int PageIndex = gvStudents.PageIndex;
   int start = PageIndex * gvStudents.PageSize + 1;
   int end = Math.Min(start + gvStudents.PageSize - 1, e.AffectedRows);
   navi.InnerHtml = string.Format("Showing record {0} - {1} of {2}", start, end, e.AffectedRows);
}

No comments:

Post a Comment