troubleshooting Question

Listbox inside gridview

Avatar of vbhargav80
vbhargav80 asked on
.NET ProgrammingC#ASP.NET
2 Comments1 Solution777 ViewsLast Modified:
Dear Experts,

I am using linq to SQL to bind my result to a gridview. I have a customers table and each customer can have multiple orders. When I query the customers table using linq, it should automatically return the list of orders for each customers as they have a foreign key relationship.

The problem is how do i bind my orders list to a listbox control inside a dridview column.

Can you please help? Followng is my code
<asp:GridView ID="gvCustomers" runat="server" AutoGenerateColumns="false">
        <asp:BoundField HeaderText="ID" DataField="ID" />
        <asp:BoundField HeaderText="Name" DataField="Name" />
        <asp:TemplateField HeaderText="Orders">
                <asp:ListBox ID="lstOrders" runat="server" DataSource="WHAT SHOULD GO HERE">
In codebehind this is how i bind
DBContext context = new DBContext ();
            var customers = from c in context.Customers
                          select new {c.Name, c.ID, c.Orders};
            gvCustomers.DataSource = customers ;
Obadiah Christopher
Developer User Interface

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 2 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros