Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
|
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 5th, 2006, 11:23 PM
Authorized User
 
Join Date: Jan 2006
Posts: 91
Thanks: 0
Thanked 0 Times in 0 Posts
Default Data Bind Template Controls in Gridview

What's the general approach to binding data controls in gridview templates? The datasource in this case is a DataTable object.

Any guidance on this would be appreciated.

Thanks!
 
Old February 6th, 2006, 01:14 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

It depends.

One way to do this is to hook up the ItemDataBound event of the GridView. Inside the event handler, you get a reference to the DataItem and then bind whatever you need to bind.

Alternatively, you can define a *DataSource object inside the template, and then parameterize the object with a control inside the template for the GridView.

What you choose depends on the data you want to bind. Can you give an example?

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old February 7th, 2006, 08:23 PM
Authorized User
 
Join Date: Jan 2006
Posts: 91
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for your input. I was getting ahead of myself in terms of design concepts. I'm now working my way through the actual development to where I'll need that feature...I'll provide an example (or let you know I've figured it out) hopefully in the next several days. I appreciate the help.
 
Old February 3rd, 2007, 10:19 PM
Authorized User
 
Join Date: Jan 2007
Posts: 54
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I have a situation with GridView. Gridview contains fields, one of which is foreign key (integer) but I want to show the description from the parent table e.g.

Table1: Client (Code, Name, Address etc)
Table2: JobMaster (Job, ClientCode, Date etc)

Now there is an ObjectDataSource connected with Table2's DAL and gridview is connected with this ObjectDataSource. Rather than showing ClientCode is gridview I would like to show Client Name which is in a different table (different DAL).

Help much appreciated

 
Old February 4th, 2007, 05:28 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

You're better off opening a new topic for this, instead of continuing an (un)related existing post.

That said, I am not sure I understand the problem. Do you have one GridView with one ObjectDataSouce on the page? Or do you have multiple and are you trying to get the name from the first into the second?

In the first case, you'll need to change the DataObject that is the source for the GridView and ObjectDataSOurce. Data that isn't there, isn't there....

In the latter case, you could hook into some event of the second GridView (ItemDataBound for example), get a reference to the other GridView and its data, and use that in the second.

HtH,

Imar
---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
Want to be my colleague? Then check out this post.
 
Old February 4th, 2007, 07:20 AM
Authorized User
 
Join Date: Jan 2007
Posts: 54
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I thought of this when I posted so I had already created a new topic at http://p2p.wrox.com/topic.asp?TOPIC_ID=55781






Similar Threads
Thread Thread Starter Forum Replies Last Post
How to bind Gridview with controls hyder_master .NET Framework 2.0 0 October 5th, 2007 05:01 AM
Beginner :: Need help to bind the data in GridView kajal C# 3 April 3rd, 2007 06:34 AM
Beginner :: Need help to bind the data in GridView kajal ASP.NET 2.0 Basics 2 April 2nd, 2007 01:21 AM
Beginner :: Need help to bind the data in GridView kajal SQL Server 2005 1 March 31st, 2007 04:26 PM
Beginner :: Need help to bind the data in GridView kajal Visual Studio 2005 2 March 31st, 2007 04:26 PM





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