Re: How to detect number of rows in a datagrid?

  • Thread starter Thread starter Alex Feinman [MVP]
  • Start date Start date
A

Alex Feinman [MVP]

The datasource property must implement IList or IListSource in order for it
to be possible to use with DataGrid. This means that you could
do the following:

IList iLst = grid.DataSource as IList;
if ( iLst == null ) // does not implement IList
{
IListSource ls = grid.DataSource as IListSource;
if ( ls != null )
iLst = ls.GetList();
}

if ( iLst != null )
count = iLSt.Count;
 
Back
Top