combo box: how to get values associated with it..please help in minutes please.....:-|

Example from MSDN:

DataTable dataTable = new DataTable("Country");
dataTable.Columns.Add("Id");
dataTable.Columns.Add("Name");
dataTable.Rows.Add(45, "Denmark");
dataTable.Rows.Add(63, "Philippines");

comboBox1.DataSource = dataTable;
comboBox1.DisplayMember = "Name";
comboBox1.ValueMember = "Id";

comboBox1.SelectedIndex = 1;
comboBox1.Refresh();

DataRow selectedDataRow = ((DataRowView)comboBox1.SelectedItem).Row;
int countryId = Convert.ToInt32(selectedDataRow["Id"]);
string countryName = selectedDataRow["Name"].ToString();

int selectedValue = Convert.ToInt32(comboBox1.SelectedValue);

thanks problem sloved..:)it was perfectly helpful for me..:)

No worries, well done! Make sure you mark this topic as resolved :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.