?
Solved

bind combo box

Posted on 2007-08-10
7
Medium Priority
?
202 Views
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.
0
Comment
Question by:suvendulaha
  • 3
4 Comments
 
LVL 96

Expert Comment

by:Bob Learned
ID: 19673040
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.

Bob
0
 
LVL 8

Accepted Solution

by:
unmeshdave earned 2000 total points
ID: 19674178
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>
0
 
LVL 8

Expert Comment

by:unmeshdave
ID: 19815017
hello,
Can you please tell the problem is solved or not? because i think the answer given is correct.
0
 
LVL 8

Expert Comment

by:unmeshdave
ID: 19825413
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.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Integration Management Part 2
Suggested Courses

807 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