473,396 Members | 2,061 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

comboBox value


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
9 7485
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
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
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
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
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
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
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

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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Zlatko Matić | last post by:
There is a form (single form) and a combobox. I want that current record of the form is adjusted according to selected value in the combobox. Cuurrent record should be the same as the value in the...
7
by: NCrum | last post by:
I want to set the Default value of a Combobox for any changeable record and have got this working but it is totaly unsatisfactory see the code below I loop through the items in the Combo looking...
3
by: PeterZ | last post by:
G'day, After doing much searching and pinching bits of ideas from here there and everywhere I came up with a fairly 'clean' solution of including a comboBox into a dataGrid column. You can...
2
by: Don | last post by:
I've looked high and low for some code that will allow me to have a combobox with a flat borderstyle. I found a few examples, but nothing that was really usable for me. I had the following...
4
by: jon f kaminsky | last post by:
Hi- I've seen this problem discussed a jillion times but I cannot seem to implement any advice that makes it work. I am porting a large project from VB6 to .NET. The issue is using the combo box...
6
by: Matt | last post by:
I'm not entirely sure how to describe this issue. I have a number of ComboBoxes in my application which have their text properties bound to a field in a data set. The items loaded in the ComboBox...
6
by: dbuchanan | last post by:
VS2005 I've been reading all the help I can on the topic (MSDN, other) but I can't make sense of this. Desired behavior; The user is to choose from the displayed list of the databound combobox...
4
by: Jerad Rose | last post by:
I'm baffled by this -- is there not a typed object used for ComboBox Items? Best I can tell, all of the methods for ComboBox that accept an Item are of type Object. Why in the world is a...
1
by: Andrus | last post by:
I need to enter null value from combobox to business object property. My combobox datasource does not contain ValueMember with null value. So I tried to create combobox which stores null to bound...
1
by: Man4ish | last post by:
Hi, How Eventlistner can be used with rendred combo box. I got one example of combobox in table as follows . /* * Copyright (c) 1995 - 2008 Sun Microsystems, Inc. All rights reserved. * ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.