Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6024865
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T04:13:05+00:00 2026-05-23T04:13:05+00:00

Here’s the problem I’m having in my ASP.NET web-form project. I have Datalist which

  • 0

Here’s the problem I’m having in my ASP.NET web-form project.

I have Datalist which shows all Products from Database , Each product have one or more colors .
At the moment i write queries like this in order to show all product and default photo of that but not colors related to that product :

var query = from p in db.Products
                        from c in db.Pics
                        where c.ProductId == p.ProductId
                        where c.IsDefault == true
                        select new { p.ProductId, p.ProductType, p.Name, p.Number, p.Package, p.Model, p.Size, p.Material, p.MantoLengh, c.PicAddress};

            DataList1.DataSource = query;
            DataList1.DataBind();

I don’t know how to bind related colors to a list-control ( like datalist or other list-Controls) inside of my DataList control, here is a view of my database diagram for more information :

enter image description here

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T04:13:06+00:00Added an answer on May 23, 2026 at 4:13 am

    I think this query would work though I apologise in advance if my syntax is slightly out, am more VB than C#…

            var query = from p in db.Products 
                        select new { p.ProductId, 
                            p.ProductType, 
                            p.Name, 
                            p.Number, 
                            p.Package, 
                            p.Model, 
                            p.Size, 
                            p.Material, 
                            p.MantoLengh, 
                            p.Pics.Where(x => x.IsDefault).Select(x => x.PicAddress).ToList(), 
                            p.Colors.Select(x => x.ColorHex).ToList() };
    

    Basically, in the anonymouse type you select you can use lambda to fetch the one-to-many collections using Select().ToList(), and use .Where() to perform filtering.

    Hope that helps.

    EDIT – In response to your comment:

    I chose the hex colour strings because they looked like the best bet for creating the actual colours. To cerate a colour from Hex, see this article. Where on the list do you want to add the colours?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here's a problem I ran into recently. I have attributes strings of the form
Here is the issue I am having: I have a large query that needs
Here is my code, which takes two version identifiers in the form 1, 5,
Here is my problem : I have a post controller with the action create.
Here's the setup - I have a view that lists products. On that same
Here is a scenario: User installs .NET application that you have made. After some
Here is my problem...I have a page that loads a list of clients and
Here is an example: I have a file 1.js, which has some functions. I
Here's my scenario - I have an SSIS job that depends on another prior
Here's a coding problem for those that like this kind of thing. Let's see

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.