selecting value from database populated combobox RRS feed

  • Question

  • hi
    i have problem in select a value form a combo box which is populated from a data source(Ds),ii have assign a display mamber.
    just want that each time the selected item change the equivalent value being (in our case the same as the text value) displayed in a label
    label1.text = combobox1.selectedvalue.tostring();

     but each time a do it a get  a system.datarowview thing been displayed:
    i then try this from a post that i found :
    label1.Text = (String)comboBox1.Items[comboBox1.SelectedIndex]
    but it still let me know that it can't do the conversion
    Saturday, May 16, 2009 12:51 PM


  • hi , i finally figured it out :
    SqlConnection conn = new SqlConnection("....");
    SqlDataAdapter Da = new SqlDataAdapter("GetEmp",conn);
    Dataset Ds= new DataSet();
    combobox1.Datasource= Ds.Tables[0];
    combobox1.DisplayMember = "Title";
    label1.Text = combobox1.Selectedvalue.toString();
    but i still don't get why the Value Member is required the information are fetch from a Database why specify again the value member ?
    Wednesday, May 20, 2009 11:38 AM