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 7173205
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T15:46:32+00:00 2026-05-28T15:46:32+00:00

I have an object Orders (Order, Product, Cost, Price, Client, Day). I am retrieving

  • 0

I have an object Orders (Order, Product, Cost, Price, Client, Day).
I am retrieving a lot of records from the database and to facilitate filtering, I need to pouplate DropDownLists with the distinct values retrieved so the user can select only specific dates or specific products or even a specific price. The IDs of the DropDownList are created as “ddl_” + name of the concerned field.

What I’d like is to be able to define a simple array like this:

public string[] filterArray = new string[] { "Order", "Product", "Cost", "Price", "Client", "Day" };

Then call a BindDLLs method:

foreach (string filterName in filterArray)
{
    // Find the ddl to populate
    DropDownList ddl = (DropDownList)this.FindControl("ddl_" + filterName);
    // Get the data for that ddl only (use filterName in the select...)
    var query = (from items in results select items.filterName.ToString()).Distinct();

    // Populate the ddl (not complete code...)
    foreach (var item in query)
    {
        ddl.Items.Add(item...);
    }
}

My problem is that I find plenty of documentation on how to modify the WHERE or GROUP BY or any other parts of linq statements at run-time. I just don’t find any on how to change dynamically the field I want to retrieve.

Is there an easy way to do this? Thank you.
Yipi

Edit:

List<Orders> results = OrdersService.GetOrders();

public class Orders
{
    [DataMember]
    public DateTime? Day
    [DataMember]
    public int? Order
    [DataMember]
    public int? Product
    [DataMember]
    public int? Cost
    [DataMember]
    public int? Price
    [DataMember]
    public int? Client
    [DataMember]
}
  • 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-28T15:46:33+00:00Added an answer on May 28, 2026 at 3:46 pm

    http://weblogs.asp.net/scottgu/archive/2008/01/07/dynamic-linq-part-1-using-the-linq-dynamic-query-library.aspx

    var query = "....";
    query = query.Select("PropName");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a basic Customer/Order/OrderItem/Product object graph. Customer has Many Orders, Order has Many
In order to do object picking in OpenGL, do I really have to render
I have a DAL to CRUD product data. For example: Order someOrder = new
I have a database for product SKU's and options related to those SKU_ID's. I
New to document-oriented database concepts and have a few high-level questions related to orders
For example, say I have two tables, Product and Order . Product has ID
i am using kohana ORM in order to get some results from the database.
I have a page where a user can insert some order about some product.
I have a product image class. This is an object with re-use potential for
I have problem with saving object to database with NHibernate. Program throws no error

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.