tags:

views:

52

answers:

4
+1  Q: 

Combo Box Question

I have added items in a combo box using datatable and rows. First it returned the value, and now it's returning dataRow. I don't know the reason why it's returning like that. Can anyone help?

string selectedValue = cbx_language.Text.ToString();
+3  A: 

It should be

string selectedValue = cbx_language.SelectedValue
NLV
A: 

Use string selectedValue = cbx_language.SelectedItem.ToString

This way, it does not matter what type of items you add using Items.Add/Insert.

logicnp
Ya I got it.. Thanks All.. I assigned using dataset.. So i had problem.. Now i assigned using Display Member and Value..
Gokulakrishnan
A: 

Is the value you are getting is System.data.datarow? & if It is then Please set valueMember & DisplayMember properties of combo box to the column name u fetching in datatable.

amol kadam
A: 

try this

string selectedValue = cbx_language.SelectedValue.ToString()
Johnny