473,659 Members | 3,631 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

comboBox value


Hello ,I am trying to get the comboBox value but when I am writing:
MessageBox.Show (this.comboBoxd b.SelectedValue .ToString());
I get the following result:
System.Data.Dat aRowView
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 7505
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******** ******@tk2msftn gp13.phx.gbl...

Hello ,I am trying to get the comboBox value but when I am writing:
MessageBox.Show (this.comboBoxd b.SelectedValue .ToString());
I get the following result:
System.Data.Dat aRowView
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******** ******@tk2msftn gp13.phx.gbl...

Hello ,I am trying to get the comboBox value but when I am writing:
MessageBox.Show (this.comboBoxd b.SelectedValue .ToString());
I get the following result:
System.Data.Dat aRowView
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)t his.comboBoxdb. SelectedValue). Row[this.comboBoxdb .ValueMember
].ToString()

--
Tim Wilson
..Net Compact Framework MVP

"juli jul" <ju******@yahoo .com> wrote in message
news:ug******** ******@TK2MSFTN GP12.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)t his.comboBoxdb. SelectedValue). Row[this.comboBoxdb .ValueMember
].ToString()

--
Tim Wilson
..Net Compact Framework MVP

"juli jul" <ju******@yahoo .com> wrote in message
news:ug******** ******@TK2MSFTN GP12.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******** ******@TK2MSFTN GP12.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
12090
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 combobox. What is the solution? Thank you in advance.
7
23527
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 for a match between cVal and the selectedValue then stop when I do have a match the obvious problem is that each iteration fires the selectedIndexChanged but also for a large list this will slow everything down. There must be a better way int...
3
3024
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 download a fully working C# sample with the Northwind.mdb here: www.insightgis.com.au/web/stuff/DataGridCombo.zip
2
6195
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 criteria that I wanted to meet, but nothing did: - No reliance on a separate library - No unmanaged code - Easy subclassing of System.Windows.Forms.Combobox (i.e. no custom control monstrosity) - No extra funky features that I didn't need
4
4611
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 bound to a table as a lookup, drawing values from another table to populate the available selections. This all worked fine in VB6. I have distilled the problem down to a simple form drawing data from the Northwind database for a representative...
6
4905
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 are not data bound (they just use the built in collection property of the ComboBox), and they are all set to use the DropDownList style. When moving from record to record via a BindingNavigator or a DataGridView (in master/detail format), the text...
6
2874
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 and the coresponding 'Id' from the lookup table is to be inserted into the field of the new record. I have two simple tables. "tblPerson" is the data table. The lookup
4
6661
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 common/standard .NET control accepting an Object as a parameter type? In Web Forms, there is a ListItem object that can be passed in to add/retrieve objects from a DropDownItems collection. I searched Google groups, and all the solutions I'm finding...
1
4231
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 object when text is deleted. However bound object contains old value in this case. To reproduce: 1. Run code
1
3537
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. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met:
0
8337
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8628
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7359
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6181
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5650
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4175
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4335
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2754
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1739
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.