TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
G F
NA
44
6.6k
Passing ID and Name of Selected Item from Combo Box
Feb 4 2020 4:30 PM
Hi,
I have a form with a combo Box, that is populated by pulling names in from a Database Table when it loads:
con.Open();
MySqlCommand sc = new MySqlCommand("SELECT CustomerName from bbb.Customers", con);
MySqlDataReader reader;
reader = sc.ExecuteReader();
DataTable dt = new DataTable();
dt.Columns.Add("CustomerName", typeof(string));
dt.Load(reader);
comboBox1.ValueMember = "CustomerName";
comboBox1.DataSource = dt;
con.Close();
I can get the data no problem, but I need the associated ID with it. The ID is Column 1, and Customer Name is Column 2. How can I the ID? Do I have to add the code in 'SelectedIndexChanged' property?
Thank you!
Reply
Answers (
1
)
TextFragmentCollection of Aspose.Pdf is taking too much time
simple calculator using mvc c#