Count records in Datatable with ObjectDataSource


/ Published in: C#
Save to your folder(s)

Get number of records in DataTable when calling a method with ObjectDataSource.


Copy this code and paste it in your HTML
  1. protected void ObjectDataSource1_Selected(object sender, ObjectDataSourceStatusEventArgs e)
  2. {
  3. if (e.Exception == null)
  4. {
  5. DataTable dt = (DataTable)e.ReturnValue;
  6. if (dt != null)
  7. TotalLabel.Text = dt.Rows.Count.ToString();
  8. else
  9. TotalLabel.Text = "0";
  10. }
  11. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.