By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,068 Members | 1,210 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,068 IT Pros & Developers. It's quick & easy.

comboBox value

P: n/a

Hello ,I am trying to get the comboBox value but when I am writing:
MessageBox.Show(this.comboBoxdb.SelectedValue.ToSt ring());
I get the following result:
System.Data.DataRowView
instead of the selected value . Why?
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 17 '05 #1
Share this Question
Share on Google+
9 Replies


P: n/a
You'll get that "value" being returned because you're data binding to the
ComboBox. Cast the SelectedValue to a DataRowView and then you can get the
appropriate value from the Row property and desired column.

--
Tim Wilson
..Net Compact Framework MVP

"juli jul" <ju******@yahoo.com> wrote in message
news:en**************@tk2msftngp13.phx.gbl...

Hello ,I am trying to get the comboBox value but when I am writing:
MessageBox.Show(this.comboBoxdb.SelectedValue.ToSt ring());
I get the following result:
System.Data.DataRowView
instead of the selected value . Why?
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 17 '05 #2

P: n/a
You'll get that "value" being returned because you're data binding to the
ComboBox. Cast the SelectedValue to a DataRowView and then you can get the
appropriate value from the Row property and desired column.

--
Tim Wilson
..Net Compact Framework MVP

"juli jul" <ju******@yahoo.com> wrote in message
news:en**************@tk2msftngp13.phx.gbl...

Hello ,I am trying to get the comboBox value but when I am writing:
MessageBox.Show(this.comboBoxdb.SelectedValue.ToSt ring());
I get the following result:
System.Data.DataRowView
instead of the selected value . Why?
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 17 '05 #3

P: n/a
Thanks but I the casting fails - how can I do it (I tried to create new
DataRowView and than asign the SelectedValue to it but it didn't work)
How to do it?
Thank you!

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 17 '05 #4

P: n/a
Thanks but I the casting fails - how can I do it (I tried to create new
DataRowView and than asign the SelectedValue to it but it didn't work)
How to do it?
Thank you!

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 17 '05 #5

P: n/a
Try something like this.

((DataRowView)this.comboBoxdb.SelectedValue).Row[this.comboBoxdb.ValueMember
].ToString()

--
Tim Wilson
..Net Compact Framework MVP

"juli jul" <ju******@yahoo.com> wrote in message
news:ug**************@TK2MSFTNGP12.phx.gbl...
Thanks but I the casting fails - how can I do it (I tried to create new
DataRowView and than asign the SelectedValue to it but it didn't work)
How to do it?
Thank you!

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 17 '05 #6

P: n/a
Try something like this.

((DataRowView)this.comboBoxdb.SelectedValue).Row[this.comboBoxdb.ValueMember
].ToString()

--
Tim Wilson
..Net Compact Framework MVP

"juli jul" <ju******@yahoo.com> wrote in message
news:ug**************@TK2MSFTNGP12.phx.gbl...
Thanks but I the casting fails - how can I do it (I tried to create new
DataRowView and than asign the SelectedValue to it but it didn't work)
How to do it?
Thank you!

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 17 '05 #7

P: n/a
How do you bind the data to the comboBox?
Try to use 2 property during binding will help you DisplayMember &
ValueMember.

"juli jul" <ju******@yahoo.com> wrote in message
news:ug**************@TK2MSFTNGP12.phx.gbl...
Thanks but I the casting fails - how can I do it (I tried to create new
DataRowView and than asign the SelectedValue to it but it didn't work)
How to do it?
Thank you!

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 17 '05 #8

P: n/a

That's the way I am binding the data to combobox:
this.comboBoxdb.DataSource =
ds_db.Tables[0]; this.comboBoxdb.DisplayMember = "name";
but I can't get the selected value,how can I get it?
Thanks!

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 17 '05 #9

P: n/a
Das
hi,

When you set the valueMember property make sure it is case sensitive.

HTH

Regards,

das

"juli jul" wrote:

That's the way I am binding the data to combobox:
this.comboBoxdb.DataSource =
ds_db.Tables[0]; this.comboBoxdb.DisplayMember = "name";
but I can't get the selected value,how can I get it?
Thanks!

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 17 '05 #10

This discussion thread is closed

Replies have been disabled for this discussion.