ASP.NET 2.0: GridView.Columns.Add() problem

r_caine
08-11-2006, 03:10 AM
Hiya,

I'm having real problems programmatically adding BoundColumns to my GridView. All the documentation and examples I can find say to use the following syntax:

BoundColumn col = new BoundColumn();
col.DataField = "Title";
col.HeaderText = "Title";
grdItems.Columns.Add(col);

However, this just gives me the build errors:
The best overloaded method match for 'System.Web.UI.WebControls.DataControlFieldCollection.Add(System.Web.U I.WebControls.DataControlField)' has some invalid arguments

Argument '1': cannot convert from 'System.Web.UI.WebControls.BoundColumn' to 'System.Web.UI.WebControls.DataControlField'

Ideas?

Thanks!

r_caine
08-11-2006, 06:33 AM
Found the problem. Should have been creating a BoundField and/or HyperLinkField, etc control to be added to the GridView's.Columns collection.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum