Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > Other ASP.NET > ASP.NET 1.x and 2.0 Application Design
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
ASP.NET 1.x and 2.0 Application Design Application design with ASP.NET 1.0, 1.1, and 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.x and 2.0 Application Design section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old June 9th, 2005, 07:25 AM
Registered User
 
Join Date: Jun 2005
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default help required for using DataGrid in asp.net

Hi,

I want to display the details of Datagrid Headertext and Datavalue whatever has been bound with Datagrid columns when I click on a button by using for loop in asp.net.I was able to show the headertext but not able to show the Datafield.i have used the following code.

Sub Button7_Click(sender As Object, e As EventArgs)
dim i as integer
dim j as integer
j=DataGrid1.Columns.count-1
for i = 1 to j
Response.write(DataGrid1.Columns.item(i).HeaderTex t)
Response.write(DataGrid1.Columns(i).DataField)
Next
End sub
I am getting error on "Response.write(DataGrid1.Columnsi).DataField) "
Please help me.


  #2 (permalink)  
Old June 9th, 2005, 08:44 AM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

And that error was?

-Peter
  #3 (permalink)  
Old June 9th, 2005, 09:26 AM
Registered User
 
Join Date: Jun 2005
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Peter,
I am getting this error

Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: BC30456: 'DataField' is not a member of 'System.Web.UI.WebControls.DataGridColumn'.


  #4 (permalink)  
Old June 9th, 2005, 09:36 AM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Aha, yes indeed that is correct. DataField is not a member of that class. However, it IS a member of derived classes that provide the ability to bind to a column in the underlying data bound to a grid such as the BoundColumn class.

When you iterate thru the columns collection of the datagrid, you get DataGridColumn objects, not their final column class types (BoundColumn, TemplateColumn, etc.). So you'll need to test each DataGridColumn you iterate thru to see if it is of type BoundColumn (or which ever other types support DataField), then you can emit that field's value.

-Peter
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
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
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Proxy Authentication Required in ASP.Net appln. rajbiswas76 General .NET 2 March 2nd, 2007 09:12 AM
vb.net asp.net DataGrid krantips VS.NET 2002/2003 0 June 28th, 2006 01:22 AM
help required in datagrid dynamic template column govind ASP.NET 1.x and 2.0 Application Design 2 January 4th, 2006 11:32 AM
Help required with ASP .NET in Dreamweaver MX CFerthorney Dreamweaver (all versions) 3 September 7th, 2003 11:27 AM



All times are GMT -4. The time now is 04:53 AM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.