March 14th, 2009, 08:21 PM
Populate ComboBox from db, Select RecordID
I can populate the drop down list no problem. What I want to do is save the selected data into another table which is related via foreign key. So I want the list to show the text description(Name) but when it is selected I want the EventID to be saved.
SqlConnection conn = new SqlConnection(@"
server = .\sqlexpress;
integrated security = true;
database = HoopDataSample");
string qryEvents = @"select EventID,Name from Events order by Name";
//****Get Event Info to Fill Event Combo Box
SqlCommand cmd = new SqlCommand(qryEvents, conn);
SqlDataReader rdr = cmd.ExecuteReader();
comboBoxEvents.Items.Add(rdr); //rdr is the EventID,rdr is the Name
Last edited by alephNull; March 15th, 2009 at 10:21 PM.
Tags for this Thread
Click Here to Expand Forum to Full Width
This is a CodeGuru survey question.