474,044 Members | 2,374 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Retrieve SelectedText in ComboBox

4 New Member
Hi,

My VB.Net 2005 application is throwing the following exception when I try to retrieve the selected item from a combobox.
Conversion from type 'DataRowView' to type 'String' is not valid

The combobox's datasource is an SQL database table column.
Mycmb.DataBindi ngs.Add(New Binding("Text", BindingSource1, "ColName"))

Basically, I want to search the database table depending on whatever is selected in the combobox and pass it to the search string.

Please help.. thanks
rang.
Sep 21 '07 #1
4 2511
Plater
7,872 Recognized Expert Expert
"Conversion from type 'DataRowView' to type 'String' is not valid"

That means somewhere (probably your .SelectedItem call) you are trying to cast a DataRowView object to a string.
Cast it to a DataRowView then look at that object to find where to pull your string from.
Sep 21 '07 #2
rang1
4 New Member
How do I cast it to a 'DataRowView' and find string? A syntax would be very helpful and appreciated! :)
Sep 21 '07 #3
Plater
7,872 Recognized Expert Expert
Well, whereever you have:
mystring=mycomb obox.SelectedIt em

Change it to:
DataRowView mydrv=(DataRowV iew)mycombobox. SelectedItem;
Sep 21 '07 #4
rang1
4 New Member
That helped! Thanks a bunch for your help!
Sep 21 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

6
3073
by: Mendhak | last post by:
Hi All, When you add an object to a combobox, and run the application, you'll get something like this: System.Windows.Forms.Button, Text: Button1 (for example). Is it possible to have just the text/value in the object to be displayed in
1
1330
by: Claudia Fong | last post by:
Hi, I have a comboBox and a textbox in my form. I already can display in a comboBox the department names; what I would like to do is display in a textbox the department ID related to the department name I chose from comboBox. below is the extract of the code:
1
10980
by: ASP Yaboh | last post by:
I have a WinForm ComboBox that is populated by binding to a dataset that contains a list of employees (two columns: 1. employee id, 2. employee name). The id is bound to the ValueMember, the name to the DisplayMember. The dataset is then disposed. When an item is selected from the combobox, the value is easy to get. Yet when I try to capture the selected text I get a "DataRowView" back. I've tried to work my way through the DataRowView...
12
4743
by: Dica | last post by:
i can't seem to find a way to cast the value in my comboBox to integer. i've tried the following: short iProjectID = Convert.ToInt16(cboProjects.SelectedValue); i keep getting a "Sepcified cast is not allowed" error. how can i do this?
1
928
by: Troy | last post by:
A user control with 1 combobox 1 button has a default constructor. The control has public properties to set the combobox Datasource, DisplayMember and ValueMember properties. These are set in the Forms Load event handler. The combo box control has its text selected even though it doesnt have focus when the form displays.
2
2383
by: Gary Shell | last post by:
I have a very ODD situation. I have a RichTextBox and a button. In the button click event I have the following: me.richtextbox1.SelectedText="test" Assuming I start with "aaaabbbbcccc" in the richtext box and I place the caret between the a and b and hit the button. I get "aaaatestbbbbcccc" as expected. Then I click between the b and the c and hit the button I get:
2
2465
by: andreas | last post by:
When I select a text in a richtextbox to set de selected text in bold, regular, italic .. or non I want to do that with one click Thus I must find out if the selected text is already in bold, regular, italic...... Is there any code for this Thanks for any response
3
2224
by: Paulers | last post by:
Hello all, I have been pulling my hair out trying to figure out how to access the selected text in a combobox from another thread. I can get it working with a textbox but it does not with a combobox. Could someone be so kind as to show me an example of how this is accomplished? Many thanks in advance.
5
6475
by: mondo3 | last post by:
As shown below, I've filled a customer combobox with a customer id (named intItem) and customer name (named strItem). What would be the syntax to get the intItem after the user makes a selection? while (rsCustomer.Read()) { // Load Customer Names into combobox. intItem = Convert.ToInt32(rsCustomer.ToString()); strItem = rsCustomer.ToString(); ...
0
10337
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
12140
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
12022
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
11141
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
10309
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
8698
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
6652
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
6836
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
4944
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.