Rank: Newbie Groups: Member
Joined: 10/13/2007 Posts: 8
|
I'm using the gid control and I am trying to add a column through code, but this example below will not add the column
even if I just do grid.columns.add() it will not add the column.
For i As Integer = 0 To dt.Columns.Count - 1 Dim Col As EO.Web.GridColumn Col.DataType = EO.Web.GridColumnDataType.Auto str = dt.Columns(i).ColumnName Col.DataField = str Col.HeaderText = str Col.AllowSort = True Grid.Columns.Add(Col) Next
Error I get is Col is null and MustInherit Public Class
How can I add a column to an existing grid control through code?
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,217
|
Hi Scott,
You will have to use New to create a GridColumn first. Without doing that, Col is Nothing. So of course you will get a "Col is Null" error. Also you need to decide which type of column you want to create (StaticColumn, DateTimeColumn, etc), you can not create the abstract GridColumn.
Thanks
|