Click here to Skip to main content
14,870,621 members
Please Sign up or sign in to vote.
3.67/5 (2 votes)
See more:
how to count total row in gridview?
Posted
Comments
[no name] 28-Mar-14 16:10pm
   
Can you not use the Rows.Count property for some reason?
Richard C Bishop 28-Mar-14 16:26pm
   
Put that as the answer, except maybe elaborate a bit.
Member 10694442 28-Mar-14 16:26pm
   
i m new in .net
i dont know which property is use

GridView1.Rows.Count;
   
v2
Comments
[no name] 28-Mar-14 23:17pm
   
Yes simple,
This is the right answer
Ankur Ramanuj 29-Mar-14 2:12am
   
this is right answer.
C#
GridView1.DataSource = dt; // dt => datatable
GridView1.DataBind();
int totalRows= dt.Rows.Count;


-KR
   
hello.. see here

datatable dt=new datatable();
datadapter da=new dataadapter();

da.fill(dt);

gridview.datasource=dt;
gridview.bind();
if(gridview.Rows.count>0)
{
here assign your gridview.Rows[0]["column name"].Tostring();
}
   
v2
   
int count=Gridview1.Rows.Count
   
DataTable dt = New DataTable();
dt= Your Function
int count= dt.Rows.Count();
   
Comments
Krunal Rohit 29-Mar-14 14:46pm
   
Count is not a method. It's property of object DataTable.

-KR

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900