views:

59

answers:

1

i have a record of a gridviewrowcollection. and i'm having issues with adding them to the grid.

GridViewRowCollection dr = new GridViewRowCollection(list);
StatisticsGrid.DataSource = dr;

doesnt work.

StatisticsGrid.Rows

does have an add method, what is strange

how can i add a gridviewrowcollection without creating a datatable + binding it to the datasource??

thanks in advance

+2  A: 

A GridView needs to be bound to a DataSource of some type. The GridViewRowCollection is immutable.

Depending on what you want to bind you might find it more fitting to bind to a generic list. This has the benefits over a DataSet of being strongly-typed and more naturally fitting to a domain-model:

IList<MyClass> data = // Get List<MyClass> of your data
StatisticsGrid.DataSource = data;
David Neale