A
Andy Fish
Hi,
I have some data which is stored as an array (or possibly an arraylist) of
identically typed objects, each of which has certain public properties. I
want to display these in a datagrid control.
According to the documentation, the datasource of a datagrid can be anything
which implements IEnumerable (which includes array and arraylist). However,
every example I've seen for datagrid uses a DataTable to store the data.
is there any way to achieve this?
here's a sample code snippet which doesn't work but I hope it illustrates
what I'm trying to do:
class person {
string firstname;
string lastname;
}
person[] people = GetListOfPeople();
DataGrid.dataSource = people;
DataGrid.columns.add(new BoundColumn("firstname"))
DataGrid.columns.add(new BoundColumn("lastname"))
DataGrid.DataBind();
many thanks
Andy
I have some data which is stored as an array (or possibly an arraylist) of
identically typed objects, each of which has certain public properties. I
want to display these in a datagrid control.
According to the documentation, the datasource of a datagrid can be anything
which implements IEnumerable (which includes array and arraylist). However,
every example I've seen for datagrid uses a DataTable to store the data.
is there any way to achieve this?
here's a sample code snippet which doesn't work but I hope it illustrates
what I'm trying to do:
class person {
string firstname;
string lastname;
}
person[] people = GetListOfPeople();
DataGrid.dataSource = people;
DataGrid.columns.add(new BoundColumn("firstname"))
DataGrid.columns.add(new BoundColumn("lastname"))
DataGrid.DataBind();
many thanks
Andy