views:

614

answers:

2

How do you find the number of rows in a DataGrid using .net compact framework?

+1  A: 

Try querying the binding context of the DataGrid: DataGrid.BindingContext[DataGrid.DataSource].Count

Or, assuming the data source is a DataTable and you know something about the data source, you can also try ((DataTable)dataGrid1.DataSource).Rows.Count or the equivalent.

lc
I am using a DataReader or else I would have found the number of rows from that.
runxc1 Bret Ferrier
A: 

Are you using a DataReader with a DB SQL call? If so you can use multiple resultsets to return the row count in your SQL call.

Here's a good example of what I'm describing at the link below.

Determine how many records the DataReader is about to return

CJCraft.com