no

How to Get Combobox Selected Value in C#

combo.ValueMember = "variate_id"; combo.DisplayMember = "variate_name"; combo.DataSource = dataset.Tables[0]; What...


combo.ValueMember = "variate_id";
combo.DisplayMember = "variate_name";
combo.DataSource = dataset.Tables[0];


What happened here is when I bind the DefaultView of the table to the ComboBox object, I get a DataRowView as SelectedValue/SelectedIndex, which is not what I wanted to.

What work for me is to get the DataRowView and get the SelectedValue in ItemArray


DataRowView row = (DataRowView)combo.SelectedItem;
int x = (int)row.Row.ItemArray[0]; //this will return the selected variate_id


I wonder why SelectedValue is not working, the way it works on the web counterpart.

Related

c# 1097047548510640554

Post a Comment Default Comments

Outsourcing

Are you looking for freelancers in the Philippines? Get in touch.

Donations

If you like what I do, you can support this channel by buying me a coffee. I would be grateful for your contribution! Your donations will help me create more FREE online courses and learning materials for programmers and remote workers.

item