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.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Ramesh MaruthiRank #937 · 2.2K reputationPosted Aug 11, 2014, 8:01 AM EDT
// 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;