Friday, July 1, 2011

Displaying Pageresults of a Gridview/Datalist

lblPageinfo.Text="Showing results: " + (_PageDataSource.CurrentPageIndex * _PageDataSource.PageSize + 1) + "-" + (_PageDataSource.CurrentPageIndex * _PageDataSource.PageSize + dlSearchJobs.Items.Count) + " of " + _PageDataSource.DataSourceCount ;

  • where _PageDataSource is the object of PagedDataSource class
  • PagedDataSource _PageDataSource = new PagedDataSource();
  • dlSearchJobs is the Datalist used to display results from DB

output : Showing results: 1-10 of 43

if using GRIDVIEW

lblPageinfo.Text="Showing results: " +(gvInbox.PageIndex) * gvInbox.PageSize + 1) + "-" + (gvInbox.PageIndex* gvInbox.PageSize+ gvInbox.Rows.Count) + " of " + objData.Length ;

  • where gvInbox is the Gridview
  • objData is the Datasource for Gridview