Welcome to Dream.In.Code
Become a VB.NET Expert!

Join 150,068 VB.NET Programmers for FREE! Get instant access to thousands of VB.NET experts, tutorials, code snippets, and more! There are 1,810 people online right now. Registration is fast and FREE... Join Now!




ctype datarowview to integer

 
Reply to this topicStart new topic

ctype datarowview to integer

Hanzie
29 Feb, 2008 - 01:13 PM
Post #1

D.I.C Head
**

Joined: 19 Aug, 2007
Posts: 92


My Contributions
Is it possible to change a datarowview object to an integer?
User is offlineProfile CardPM
+Quote Post

PsychoCoder
RE: Ctype Datarowview To Integer
29 Feb, 2008 - 02:21 PM
Post #2

using DIC.Core;
Group Icon

Joined: 26 Jul, 2007
Posts: 9,483



Thanked: 161 times
Dream Kudos: 9075
Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, Boo.Net

My Contributions
You cannot convert the actual DataRowView to an integer, but you can convert it's value to an Integer as the SelectedItem() value will always be DataRowView, which cannot be converted. Use the SelectedValue.ToString(), like so


vb

BedrID = CType(BedrijvenIDListBox.SelectedValue.ToString(), Integer)


You can also use


vb

BedrID = Convert.ToInt32(BedrijvenIDListBox.SelectedValue.ToString())

User is offlineProfile CardPM
+Quote Post

Hanzie
RE: Ctype Datarowview To Integer
29 Feb, 2008 - 02:34 PM
Post #3

D.I.C Head
**

Joined: 19 Aug, 2007
Posts: 92


My Contributions
Errors wich i get with the folowing conversions:

vb

BedrID = CType(BedrijvenIDListBox.SelectedValue.ToString(), Integer)


Error: Conversion from string "System.Data.DataRowView" to type 'Integer' is not valid.

vb

BedrID = Convert.ToInt32(BedrijvenIDListBox.SelectedValue.ToString())


Error: Input string was not in a correct format.
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/8/09 10:54PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live VB.NET Help!

VB.NET Tutorials

Reference Sheets

VB.NET Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month