-1

In asp.net , I need to assign back the values to textbox,dropdown and combobox values back to respective controls. I already prepopulated those dropdown and combobox with their respective values. I can see value in dropdown but not not in combobox since combobox is multiselector with Comma (',').

Note : I m getting comma seperated values as one single string and assigning to combobox . I tried with the below code, but the combobox is not getting its value back.

        if (oDs.Tables[0].Rows.Count > 0)
        {
         if (oDs.Tables[0].Rows.Count == 1)
            {
              textbox1.Text = oDs.Tables[0].Rows[0].ItemArray[0].ToString();
              textbox2.Text = oDs.Tables[0].Rows[0].ItemArray[1].ToString();
              textbox3.Text = oDs.Tables[0].Rows[0].ItemArray[2].ToString();
              dropdown1.SelectedItem.Text = oDs.Tables[0].Rows[0].ItemArray[4].ToString();

        dropdown2.SelectedItem.Text = oDs.Tables[0].Rows[0].ItemArray[5].ToString();

      combbox1.SelectedText =oDs.Tables[0].Rows[0].ItemArray[6].ToString();**
                                }
                            }
                        } 
LOKI
  • 312
  • 1
  • 4
  • 17
  • Possible duplicate of [How do I set the selected item in a comboBox to match my string using C#?](http://stackoverflow.com/questions/450059/how-do-i-set-the-selected-item-in-a-combobox-to-match-my-string-using-c) – LOKI Nov 24 '16 at 14:50

1 Answers1

1

Try something like this:

    string[] csvFields = csvString.Split(',');
    comboBox1.ItemsSource = csvFields;  
Failed Scientist
  • 1,977
  • 3
  • 29
  • 48