Bound Control

J

Jim Heavey

Hello, when you have bound a datatable to a control, say a comboBox and you
have set the "ValueMember" and the "DisplayMenber". The cbo.SelectedValue
returns the object which equates to the "ValueMember", but how do you
retrieve the object which is associated with the Display Member? I have
tried cbo.SelectedText, but that does not seem to do...I have tried
cbo.SelectedItem...but again does not seem to do it which the control is
bound.

This only way that I have found to get the value is to use the
cbo.SelectedIndex and use this as a pointer back into the DataTable which
is bound to the control. Surely there is a better way....

What is the difference between selected Text and Selected Item?

Thanks in advance for your assistance!!!!!!!!!!!!
 
G

Guest

Hi Jim

Have you tried 'cbo.Items[cbo.SelectedIndex]

thank
Nithin P

----- Jim Heavey wrote: ----

Hello, when you have bound a datatable to a control, say a comboBox and you
have set the "ValueMember" and the "DisplayMenber". The cbo.SelectedValue
returns the object which equates to the "ValueMember", but how do you
retrieve the object which is associated with the Display Member? I have
tried cbo.SelectedText, but that does not seem to do...I have tried
cbo.SelectedItem...but again does not seem to do it which the control is
bound

This only way that I have found to get the value is to use the
cbo.SelectedIndex and use this as a pointer back into the DataTable which
is bound to the control. Surely there is a better way...

What is the difference between selected Text and Selected Item

Thanks in advance for your assistance!!!!!!!!!!!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top