473,386 Members | 1,610 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,386 software developers and data experts.

Retrieve SelectedText in ComboBox

4
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.DataBindings.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 2475
Plater
7,872 Expert 4TB
"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
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 Expert 4TB
Well, whereever you have:
mystring=mycombobox.SelectedItem

Change it to:
DataRowView mydrv=(DataRowView)mycombobox.SelectedItem;
Sep 21 '07 #4
rang1
4
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
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...
1
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...
1
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...
12
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...
1
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...
2
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...
2
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,...
3
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...
5
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? ...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.