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

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;
 

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