bind combo box

Posted on 2007-08-10
Last Modified: 2013-12-17
Hi Expert,
   I have two table. One Product ( id, type_id, name, price) and ProductType(Type_id, name, description). Now In from I want to neviogate the product . The Type_id will be in ComboBox).

Plaese tell me how to bind combo box.
Question by:suvendulaha
    LVL 96

    Expert Comment

    by:Bob Learned
    Windows Forms example:

    this.comboBox1.DataSource = this.dataSet1.Tables("Product");
    this.comboBox1.DisplayMember = "name";
    this.comboBox1.ValueMember = "type_id";

    For ASP.NET that would be slightly different.

    LVL 8

    Accepted Solution

    Following is the way to bind your combobox(as u asked) with required field values in ASP.NET.
    Hope this wil help u.

    <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<YOUR CONNECTIONSTRING>"
                SelectCommand="SELECT [type_id] FROM [Product]"></asp:SqlDataSource>

    <asp:ListBox ID="ListBox1" runat="server" DataSourceID="SqlDataSource2" DataTextField="type_id" DataValueField="type_id"></asp:ListBox>
    LVL 8

    Expert Comment

    Can you please tell the problem is solved or not? because i think the answer given is correct.
    LVL 8

    Expert Comment

    Hi TheLearnedOne,
    If the problem is not solved with given suggestions, there should be a comment from the author, with the reason that what is the output with given suggestion. I guess the solution given is the right one.

    Featured Post

    Courses: Start Training Online With Pros, Today

    Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

    Join & Write a Comment

    For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK ( for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
    Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!
    In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now