How to get row count in dataGrid C#

  • Thread starter Thread starter J
  • Start date Start date
J

J

Does anyone know how to get the row count for a datagrid? It seems
like it should be simple, alas it is not.

datagrid1.GetRowCount?
 
A DataGrid is a display widget, not a container for records. What would
RowCount be anyway -- displayed rows, or total rows?

I think you will have to examine this at the level of the underlying data
table or binding manager or whatever.

--Bob
 
J said:
Does anyone know how to get the row count for a datagrid? It seems
like it should be simple, alas it is not.

datagrid1.GetRowCount?

You use the row count of the returned records in the appropriate table
of your dataset:

int iCnt;
iCnt = this.BindingContext[datasetname, "tablename"].Count;
 
Back
Top