Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Sep 20, 2011 07:02 PM by atconway
Member
20 Points
11 Posts
Sep 15, 2011 08:51 AM|LINK
Like C# can with this code:
((GridView)Container.NamingContainer).PageIndex + 1
All-Star
73649 Points
7914 Posts
Moderator
Sep 15, 2011 09:18 AM|LINK
In VB.NET, it should works without any casting:
Container.NamingContainer.PageIndex + 1
Sep 16, 2011 01:45 AM|LINK
I got this error:
'PageIndex' is not a member of 'System.Web.UI.Control'.
Sep 17, 2011 09:33 AM|LINK
Not sure why the implicit conversion is not working.You can try the explicit conversion like this:
Ctype(Container.NamingContainer,GridView).PageIndex + 1
644 Points
152 Posts
Sep 17, 2011 10:05 PM|LINK
DirectCast(Container.NamingContainer,GridView).PageIndex + 1
is the equivilant to the above C# syntax
16846 Points
2756 Posts
Sep 20, 2011 07:02 PM|LINK
If you want to understand why you have to cast the NamingContainer to its type and how to do it in the future, have a look to the following:
How to: Access Members of a Control's Naming Container
http://msdn.microsoft.com/en-us/library/858twd77.aspx
l1k3m1k3
Member
20 Points
11 Posts
Elegant VB.NET Data Type Conversion
Sep 15, 2011 08:51 AM|LINK
Like C# can with this code:
anas
All-Star
73649 Points
7914 Posts
Moderator
Re: Elegant VB.NET Data Type Conversion
Sep 15, 2011 09:18 AM|LINK
In VB.NET, it should works without any casting:
l1k3m1k3
Member
20 Points
11 Posts
Re: Elegant VB.NET Data Type Conversion
Sep 16, 2011 01:45 AM|LINK
I got this error:
'PageIndex' is not a member of 'System.Web.UI.Control'.
anas
All-Star
73649 Points
7914 Posts
Moderator
Re: Elegant VB.NET Data Type Conversion
Sep 17, 2011 09:33 AM|LINK
Not sure why the implicit conversion is not working.You can try the explicit conversion like this:
rossmc1
Member
644 Points
152 Posts
Re: Elegant VB.NET Data Type Conversion
Sep 17, 2011 10:05 PM|LINK
DirectCast(Container.NamingContainer,GridView).PageIndex + 1
is the equivilant to the above C# syntax
atconway
All-Star
16846 Points
2756 Posts
Re: Elegant VB.NET Data Type Conversion
Sep 20, 2011 07:02 PM|LINK
If you want to understand why you have to cast the NamingContainer to its type and how to do it in the future, have a look to the following:
How to: Access Members of a Control's Naming Container
http://msdn.microsoft.com/en-us/library/858twd77.aspx