473,657 Members | 2,567 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DropDownList in DataGrid and SQL Query with Child Rows

I have made a Template column in my DataGrid that contains a DropDownList.
My main SQL query that is bound to this datagrid joins with another table in
the following way:

SELECT * FROM Customer
INNER JOIN Orders ON Orders.Customer ID = Customer.Custom erID

So I will get multiple rows returned for each customer per their orders.
I want to only show the customer once and have the DropDownList contain that
customer's orders. How do I do this?

Thanks,

John
Nov 17 '05 #1
2 1496
You can user Group by.

This is from Northwind:
SELECT dbo.Customers.C ustomerID, dbo.Customers.C ompanyName,
dbo.Customers.C ontactName, dbo.Customers.C ontactTitle,
dbo.Customers.A ddress,
dbo.Customers.C ity, dbo.Customers.R egion,
dbo.Customers.P ostalCode, dbo.Customers.C ountry, dbo.Customers.P hone,
dbo.Customers.F ax
FROM dbo.Customers INNER JOIN
dbo.Orders ON dbo.Orders.Cust omerID =
dbo.Customers.C ustomerID
GROUP BY dbo.Customers.C ustomerID, dbo.Customers.C ompanyName,
dbo.Customers.C ontactName, dbo.Customers.C ontactTitle,
dbo.Customers.A ddress,
dbo.Customers.C ity, dbo.Customers.R egion,
dbo.Customers.P ostalCode, dbo.Customers.C ountry, dbo.Customers.P hone,
dbo.Customers.F ax

Morten

"John Bonds" <jo*******@hotm ail.com> wrote in message
news:en******** ******@TK2MSFTN GP12.phx.gbl...
I have made a Template column in my DataGrid that contains a DropDownList.
My main SQL query that is bound to this datagrid joins with another table in the following way:

SELECT * FROM Customer
INNER JOIN Orders ON Orders.Customer ID = Customer.Custom erID

So I will get multiple rows returned for each customer per their orders.
I want to only show the customer once and have the DropDownList contain that customer's orders. How do I do this?

Thanks,

John

Nov 17 '05 #2
You can user Group by.

This is from Northwind:
SELECT dbo.Customers.C ustomerID, dbo.Customers.C ompanyName,
dbo.Customers.C ontactName, dbo.Customers.C ontactTitle,
dbo.Customers.A ddress,
dbo.Customers.C ity, dbo.Customers.R egion,
dbo.Customers.P ostalCode, dbo.Customers.C ountry, dbo.Customers.P hone,
dbo.Customers.F ax
FROM dbo.Customers INNER JOIN
dbo.Orders ON dbo.Orders.Cust omerID =
dbo.Customers.C ustomerID
GROUP BY dbo.Customers.C ustomerID, dbo.Customers.C ompanyName,
dbo.Customers.C ontactName, dbo.Customers.C ontactTitle,
dbo.Customers.A ddress,
dbo.Customers.C ity, dbo.Customers.R egion,
dbo.Customers.P ostalCode, dbo.Customers.C ountry, dbo.Customers.P hone,
dbo.Customers.F ax

Morten

"John Bonds" <jo*******@hotm ail.com> wrote in message
news:en******** ******@TK2MSFTN GP12.phx.gbl...
I have made a Template column in my DataGrid that contains a DropDownList.
My main SQL query that is bound to this datagrid joins with another table in the following way:

SELECT * FROM Customer
INNER JOIN Orders ON Orders.Customer ID = Customer.Custom erID

So I will get multiple rows returned for each customer per their orders.
I want to only show the customer once and have the DropDownList contain that customer's orders. How do I do this?

Thanks,

John

Nov 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
17003
by: Dominic | last post by:
Hi guys, I'm not sure if this question belongs to FAQ, but I couldn't find a concrete answer. I created a Datagrid control using ItemTemplate, but it's NOT a in-place editing datagrid. One of the columns of the data grid contains a DropDownlist. I managed to create this datagrid control as follows.
0
296
by: John Bonds | last post by:
I have made a Template column in my DataGrid that contains a DropDownList. My main SQL query that is bound to this datagrid joins with another table in the following way: SELECT * FROM Customer INNER JOIN Orders ON Orders.CustomerID = Customer.CustomerID So I will get multiple rows returned for each customer per their orders. I want to only show the customer once and have the DropDownList contain that customer's orders. How do I do...
1
1706
by: m3ckon | last post by:
Hi there, please help if you can, I'm having an issue with droponnlists in a datagrid I have a datagrid which is populated from a query .. all works fine I've added two extra columns, one is a dropdownlist and the other is a button which runs the command selectcode for this:
4
2098
by: wolfgang wagner | last post by:
hi all! after successfully integrating a dropdownlist in my datagrid i have another problem: i cannot set the selected index of the dropdownlistbox. here is my code: hardware.aspx -------------
0
8397
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8310
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8732
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8503
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8605
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7333
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4158
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4315
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1957
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.