Go Back  Xtreme Visual Basic Talk > Other Languages > Web Programming > ASP.NET 2.0: GridView.Columns.Add() problem


Reply
 
Thread Tools Display Modes
  #1  
Old 08-11-2006, 03:10 AM
r_caine's Avatar
r_caine r_caine is offline
Junior Contributor
 
Join Date: Oct 2003
Location: Birmingham, England
Posts: 291
Unhappy ASP.NET 2.0: GridView.Columns.Add() problem


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:

Code:
BoundColumn col = new BoundColumn();
col.DataField = "Title";
col.HeaderText = "Title";
grdItems.Columns.Add(col);
However, this just gives me the build errors:
Quote:
The best overloaded method match for 'System.Web.UI.WebControls.DataControlFieldCollection.Add(System.Web.U I.WebControls.DataControlField)' has some invalid arguments
Quote:
Argument '1': cannot convert from 'System.Web.UI.WebControls.BoundColumn' to 'System.Web.UI.WebControls.DataControlField'
Ideas?

Thanks!
__________________
Rich
Blastportal.com

Cool Link
Reply With Quote
  #2  
Old 08-11-2006, 06:33 AM
r_caine's Avatar
r_caine r_caine is offline
Junior Contributor
 
Join Date: Oct 2003
Location: Birmingham, England
Posts: 291
Default

Found the problem. Should have been creating a BoundField and/or HyperLinkField, etc control to be added to the GridView's.Columns collection.
__________________
Rich
Blastportal.com

Cool Link
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->