I have a data table that I created as below.
I am selected using a sql statement to get 1 field to appear in combo box. What I would like to do then is to get the selected items from the underlying data table that match to the item in the combo box.
So if I selected Name A out of the Combo Box I would like to be able to store all of the rest of the contents of the fields that a relevant to Name A either to an array or to Constants as they will not be changing.
Is this possible ? if so how ....
Here is a snippet of my sample code I am using.
Expand|Select|Wrap|Line Numbers
- // Create the data apadter
- SqlDataAdapter da = new SqlDataAdapter("SELECT * FROM Names ORDER by Name", cs);
- // Create the Data Table
- DataTable dt = new DataTable();
- // Fill Data Table with Records
- da.Fill(dt);
- // Loop around the table and populate the combo box with records....
- for (int i = 0; i < dt.Rows.Count; i++)
- {
- cboCouncils.Items.Add(dt.Rows[i]["Name"]);
- }
rdrunner