Casting a DataItem to a DataRowView
Messages   Related Types
This message was discovered on ASPFriends.com 'aspngvb' list.


Tony Kilhoffer
-- Moved from [aspngfreeforall] to [aspngvb] by Marcie Jones <Click here to reveal e-mail address> --

I have one line of code that doesnt seem to work in VB.Net, but does in C#.
How do you cast these types in VB? Here is the line:

Dim drv As DataRowView = e.Item.DataItem

The error states that it is an invalid cast. The same thing can be done in
C#, however. What gives?

Reply to this message...
 
    
Peter Brunone
Tony,

    Without knowing what e.Item.DataItem is, it would be hard to say. Could
you share a bit more code?

-Peter

|-----Original Message-----
|From: Tony Kilhoffer [mailto:Click here to reveal e-mail address]
|
|I have one line of code that doesnt seem to work in VB.Net, but does in C#.
|How do you cast these types in VB? Here is the line:
|
|Dim drv As DataRowView = e.Item.DataItem
|
|The error states that it is an invalid cast. The same thing can be done in
|C#, however. What gives?
|

Reply to this message...
 
    
Jaison Green
In VB.Net you cast using: CType(expression, typename)

=20
Jaison Green
Hunt Interactive
425*746*7880
=20
=20

-----Original Message-----
From: Tony Kilhoffer [mailto:Click here to reveal e-mail address]=20
Sent: Tuesday, June 04, 2002 8:49 AM
To: aspngvb
Subject: [aspngvb] Casting a DataItem to a DataRowView

-- Moved from [aspngfreeforall] to [aspngvb] by Marcie Jones
<Click here to reveal e-mail address> --

I have one line of code that doesnt seem to work in VB.Net, but does in
C#. How do you cast these types in VB? Here is the line:

Dim drv As DataRowView =3D e.Item.DataItem

The error states that it is an invalid cast. The same thing can be done
in C#, however. What gives?
| [aspngvb] member Click here to reveal e-mail address =3D YOUR ID=20
| http://www.asplists.com/asplists/aspngvb.asp =3D JOIN/QUIT

Reply to this message...
 
    
Tony Kilhoffer
I found another way around it. Thanks for responding, though!

-----Original Message-----
From: Peter Brunone [mailto:Click here to reveal e-mail address]
Sent: Tuesday, June 04, 2002 10:03 AM
To: aspngvb
Subject: [aspngvb] RE: Casting a DataItem to a DataRowView

Tony,

    Without knowing what e.Item.DataItem is, it would be hard to say.
Could
you share a bit more code?

-Peter

|-----Original Message-----
|From: Tony Kilhoffer [mailto:Click here to reveal e-mail address]
|
|I have one line of code that doesnt seem to work in VB.Net, but does in C#.
|How do you cast these types in VB? Here is the line:
|
|Dim drv As DataRowView = e.Item.DataItem
|
|The error states that it is an invalid cast. The same thing can be done in
|C#, however. What gives?
|

| [aspngvb] member Click here to reveal e-mail address = YOUR ID
| http://www.asplists.com/asplists/aspngvb.asp = JOIN/QUIT

Reply to this message...
 
    
ganesh kumar
(Type your message here)

--------------------------------
From: ganesh kumar

Hi Tony Kilhoffer

The equivalent Casting for the above Code in Vb.net is

Dim drv As DataRowView = CType(e.Item.DataItem, DataRowView)

I hope this will clear u r Doubt.
Cheers
ganesh
Reply to this message...
 
 
System.Data.DataRowView




Ad
MBR BootFX
Best-of-breed application framework for .NET projects, developed by Matthew Baxter-Reynolds and MBR IT
 
 Copyright © Matthew Baxter-Reynolds 2001-2008. '.NET 247 Software Development Services' is a trading style of MBR IT Solutions Ltd.
Contact Us - Terms of Use - Privacy Policy - www.dotnet247.com