DataField not member of 'System.Web.UI.WebControls.DataGridColumn'

  • Thread starter Thread starter tshad
  • Start date Start date
T

tshad

I am getting this error trying to dynamically added a column to my DataGrid.

I have the following code:

Function CreateBoundColumn(c as DataColumn) as DataGridColumn
Dim column as DataGridColumn = new BoundColumn()
column.DataField = c.ColumnName <----
the error
column.HeaderText = c.ColumnName.Replace("_"," ")
column.DataFormatString =setFormating(c)
return column
End Function

But the code I borrrowed this from was:

'add bound columns to the datagrid
Dim datagridcol As New BoundColumn
datagridcol.HeaderText = "Candy Type"
datagridcol.DataField = "CandyType"
DataGrid1.Columns.Add(datagridcol)

Here they use DataField the same as I do.

Am I missing something to make this work?

Thanks,

Tom
 
Back
Top