I am trying to create a COMBOBOX from SQL, and I can populate the box with the text from one column, but I need to also keep the values associated with that data element to feed a second SQL select in another COMBOBOX.
Example: When you select a state (Maine) I want to pass the FIPS code (ID from the DB) to the next SQL statement to run another SQL query. How can I do this?
SqlDataAdapter sqlFIPSAdapter = new SqlDataAdapter("SELECT DISTINCT State_FIPS_ID, State_Name " +
"FROM FIPS_Table " +
"ORDER BY State_Name;", sqlConn);
DataTable dtFIPS = new DataTable();
cb_State.DisplayMember = "State_Name";
cb_State.ValueMember = "State_FIPS_ID";
foreach (DataRow dr in dtFIPS.Rows)
this.cb_State.Text = "<Select a State>";