How to count total number of rows from datatable in c#.
DataTable DtObject=new DataTable();
int cnt=0; //initialization count as 0.
if(DtObject.Rows.Count!=null) // dt1.Rows.count will give information about total records or tital rows in datatable.
{
for (int i = 0; i < DtObject.Rows.Count-1; i++)
{
cnt += 1;
}
lblResult.Text = cnt.ToString();
}
DataTable DtObject=new DataTable();
int cnt=0; //initialization count as 0.
if(DtObject.Rows.Count!=null) // dt1.Rows.count will give information about total records or tital rows in datatable.
{
for (int i = 0; i < DtObject.Rows.Count-1; i++)
{
cnt += 1;
}
lblResult.Text = cnt.ToString();
}
0 comments: