Hi,
I have a webgrid and label in MVC 5 application. My requirement is show the total no of records present in webgrid in a label.
Thank you.
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Ramesh MaruthiPosted Aug 11, 2014, 12:01 PM
// Cast the WebDataGrid DataSource to a DataTable
DataTable dt = this._dg.DataSource as DataTable;
// Disable WebDataGrid Paging
_dg.Behaviors.Paging.Enabled = false;
// Retrieve DataTable Rows Count to display in Label
label1.Text = "Total Rows in DataTable = " + dt.Rows.Count;
// Retrieve WebDataGrid1 Rows Count displayed
label2.Text = "Total Rows in WebDataGrid = " + _dg.Rows.Count;
// Enable WebDataGrid Paging
_dg.Behaviors.Paging.Enabled = true;