How to get the rows count from datagrid???

J

Jet Leung

Hi all,
How can I get the rows count of the datagrid without count its datasource?
 
P

Paul

As I recall, DataGridName.Items.Count should return this - but be sure to do
it after it's been bound to its datasource, or you'll be counting an empty
grid.

HTH,

Paul
 
N

Nicholas Paldino [.NET/C# MVP]

Jet,

The data source for the DataGrid is always going to implement IList.
Get the data source, cast it to IList, and then use the Count property to
determine how many items are in the grid.

Hope this helps.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top