Hi,
This is the smallest sample code I know of when creating and displaying a datagrid.
ArrayList a=new ArrayList();
a.Add("hello world");
DataGrid1.DataSource=a;
DataGrid1.DataBind();

I found out that if I create disable AutoGenerateColumn I can add a boundcolumn dynamically by adding these lines.
BoundColumn bc=new BoundColumn();
bc.DataField="!";
DataGrid1.Columns.Add(bc);

Notice that "!" is a special DataField and the datagrid knows what to do with an ArrayList.

My question is how can I make new columns to work. It works if I create an entire class that supports IEnumerable,IEnumerate and each property will be a column, but I want as short source code as possible.

I have tried this:
ArrayList []a=new ArrayList[2];
a[0].Add("hello");
a[1].Add("world");

BoundColumn bc=new BoundColumn();
bc.DataField="!";
DataGrid1.Columns.Add(bc);

bc=new BoundColumn();
bc.DataField="!";
DataGrid1.Columns.Add(bc);
and so on..

Please help me solve this or point me to any resources on this.


Yours sincerely
Andla