//NOTE: this snippet is assumed to be in a codebehind event handler System.Collections.ArrayList al = new System.Collections.ArrayList(); for(int i=0; i<5; i++){ DataClass dc = new DataClass(); dc.ID = i; dc.Description = "Collection Item " + i; al.Add(dc); }
this.DataGrid1.AutoGenerateColumns = false; BoundColumn col = new BoundColumn(); col.DataField = "Description"; col.HeaderText = "Description"; this.DataGrid1.Columns.Add(col); this.DataGrid1.DataSource = al; this.DataGrid1.DataBind(); |