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

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
 
S

Sherif Elmetainy

Dim column as BoundColumn = new BoundColumn()
column.DataField = c.ColumnName
 
T

tshad

Sherif Elmetainy said:
Dim column as BoundColumn = new BoundColumn()
column.DataField = c.ColumnName

That was it.

I don't know how I missed that.

Thanks,

Tom
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,023
Latest member
websitedesig25

Latest Threads

Top