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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T02:50:26+00:00 2026-05-25T02:50:26+00:00

I have a table with 2 columns, Product ID and Product Description. In asp.NET

  • 0

I have a table with 2 columns, Product ID and Product Description. In asp.NET I am populating a dropdown list with a datatable, and the user selects a product. Therefore I still need to use the ID as the identifier, but having a product description would help so the user would know what the product is.

How is this done best?

This is what I have so far (C#):

    public static DataTable GetProductList()
    {
        DatabaseAdapter dba = DatabaseAdapter.GetInstance();
        string sqlQuery = ("SELECT PRODUCT_ID FROM PRODUCT");

        DataTable dt = new DataTable();
        dt.Load(dba.QueryDatabase(sqlQuery));
        return dt;
    }

This is where I am binding it (C#):

    private void PopulateProductList()
    {
        try
        {
            ProductList.DataSource = BusinessLayerHandler.GetUnitList();
            ProductList.DataTextField = "PRODUCT_ID";
            ProductList.DataValueField = "PRODUCT_ID";
            ProductList.DataBind();
        }
        catch
        {
            new Logging("E00080002");
            Alert("Failed to Import Product List");
        }
    }

The current result is a List of Product ID’s: 1, 2, 3, 4
and I need ID + Description: 1 – Photo Album, 2 – File, 3 – Pencil Box

Then I would need to get the value of that list, but I don’t need id + description, I only need the id as the identifier. This is where it is not yet clear, how is this done?

String productID = ProductList.SelectedValue;

I am using Oracle as my Database

  • 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-25T02:50:27+00:00Added an answer on May 25, 2026 at 2:50 am

    Try this:

    public static DataTable GetProductList()
    {
        DatabaseAdapter dba = DatabaseAdapter.GetInstance();
        // Return a second, aliased column that concatenates PRODUCT_ID
        // with " - " and DESCRIPTION (alias NEW_DESCRIPTION)
        string sqlQuery = ("SELECT PRODUCT_ID, PRODUCT_ID + " - " + DESCRIPTION AS NEW_DESCRIPTION FROM PRODUCT");
    
        DataTable dt = new DataTable();
        dt.Load(dba.QueryDatabase(sqlQuery));
        return dt;
    }
    
    private void PopulateProductList()
    {
        try
        {
            ProductList.DataSource = BusinessLayerHandler.GetUnitList();
            // Assign the NEW_DESCRIPTION column to the DataTextField
            ProductList.DataTextField = "NEW_DESCRIPTION";
            ProductList.DataValueField = "PRODUCT_ID";
            ProductList.DataBind();
        }
        catch
        {
            new Logging("E00080002");
            Alert("Failed to Import Product List");
        }
    }
    

    Essentially, select the PRODUCT_ID column and the PRODUCT_ID and DESCRIPTION columns cocatenated together – I aliased the second column for ease of reference.

    Then you can assign PRODUCT_ID to the DataValueField of the DropDownList and the concatenated column (in this case NEW_DESCRIPTION) to the DataTextField.

    EDIT

    If you simply want to get the product id (for the DropDownList value fields) and the product description for the Drop Down List option’s text, modify the Select as follows:

    string sqlQuery = ("SELECT PRODUCT ID, DESCRIPTION FROM PRODUCT");
    

    and then modify the DataTextField and DataValueField as follows:

    ProductList.DataTextField = "NEW_DESCRIPTION";
    ProductList.DataValueField = "PRODUCT_ID";
    

    The syntax for the SQL might be a little different for Oracle (I’m using SQL Server syntax), but the concept is the same – if you want one column’s value for the DropDownList’s value field and another column’s value for the DropDownList’s text field, simply select both columns from the table and assign them accordingly.

    This modification would produce a DropDownList with the following items:

    Photo Album
    File
    Pencil Box
    

    And a corresponding values for the items as:

    1
    2
    3
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following columns in a table: Product Name Quantity Description I want
I have a product table where the description column is fulltext indexed. The problem
I have a table of product information with many bit columns. This table can
I have an ASP.NET 4.0 home page which displays about 20 product listings. Each
I have a table with the following columns inspection_dt, contact_dt, description, product_mod, product_desc, contact_nm,
I have product table with columns product_id (p.k) product_name product_description product_price category_id and I
I have a product table with columns .. product_id product_name prodcut_description Now I want
I have a table products , and I have columns like product_name , product_id
I have a table with the following columns (I simplified it a little): PRODUCT_name
I have a table with column for storing product code. | product_id | Product-name

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.