2
Contributors
3
Replies
13
Views
3 Years
Discussion Span
Last Post by mmcdonald
0

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);
0

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

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.