473,473 Members | 1,764 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Findcontrol not working in VB

I am using sample code from C# and am trying to convert it to VB.Net in my
aspx page.

This works in C#:

DataGrid oGrid = (DataGrid)oItem.FindControl("DataGrid1");

I have tried all kinds of combinations trying to get it to work:

************************************************** *********************
Dim oGrid as DataGrid
oGrid =
CType(DataGrid,DataList1.Items[DataList1.SelectedIndex].FindControl("DataGrid1"))

Gives me this error:

'DataGrid' is a type and cannot be used as an expression.
************************************************** ************************************************

************************************************** ************************************************** *
Dim oGrid as DataGrid
oGrid = DataList1.Items[DataList1.SelectedIndex].FindControl("DataGrid1"))

Gives me this error:

Value of type 'System.Web.UI.WebControls.DataListItemCollection' cannot be
converted to 'System.Web.UI.WebControls.DataGrid'.
************************************************** **************************************************

************************************************** ************************************************** *******
Dim oGrid as DataGrid =
DataList1.Items[DataList1.SelectedIndex].FindControl("DataGrid1"))

Gives me:

Identifier expected.
************************************************** ************************************************** **********

************************************************** ************************************************** ***********
Dim oGrid as new DataGrid =
DataList1.Items[DataList1.SelectedIndex].FindControl("DataGrid1"))

Gives me:

End of statement expected.
************************************************** ************************************************** **********

How do I make this work?

Thanks,

Tom.
Nov 18 '05 #1
1 1879
Never mind.

The correct line should be:

Dim oGrid as DataGrid =
CType(DataList1.Items(DataList1.SelectedIndex).Fin dControl("DataGrid1"),DataGrid)

Tom

"tshad" <ts**********@ftsolutions.com> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
I am using sample code from C# and am trying to convert it to VB.Net in my
aspx page.

This works in C#:

DataGrid oGrid = (DataGrid)oItem.FindControl("DataGrid1");

I have tried all kinds of combinations trying to get it to work:

************************************************** *********************
Dim oGrid as DataGrid
oGrid =
CType(DataGrid,DataList1.Items[DataList1.SelectedIndex].FindControl("DataGrid1"))

Gives me this error:

'DataGrid' is a type and cannot be used as an expression.
************************************************** ************************************************

************************************************** ************************************************** *
Dim oGrid as DataGrid
oGrid =
DataList1.Items[DataList1.SelectedIndex].FindControl("DataGrid1"))

Gives me this error:

Value of type 'System.Web.UI.WebControls.DataListItemCollection' cannot be
converted to 'System.Web.UI.WebControls.DataGrid'.
************************************************** **************************************************

************************************************** ************************************************** *******
Dim oGrid as DataGrid =
DataList1.Items[DataList1.SelectedIndex].FindControl("DataGrid1"))

Gives me:

Identifier expected.
************************************************** ************************************************** **********

************************************************** ************************************************** ***********
Dim oGrid as new DataGrid =
DataList1.Items[DataList1.SelectedIndex].FindControl("DataGrid1"))

Gives me:

End of statement expected.
************************************************** ************************************************** **********

How do I make this work?

Thanks,

Tom.

Nov 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Ivan Demkovitch | last post by:
Hi! I have following problem: When I create control dynamically and assign ID to it it get's changed if you look at output HTML. Because I add this control inside ascx it is prefixed with...
1
by: Michael Murschell | last post by:
If I call Page.FindControl() on an aspx, it finds the control, but if I call it on an ASCX, it does not. Why not? And how would I call it?
10
by: Terry Olsen | last post by:
I've got a datagrid set up to display data. I've also got an Edit,Update,Cancel column set up to allow editing of data. I've got a DropDownList (ID="ddl3")in the EditItemTemplate for a certain...
1
by: Schultz | last post by:
Hi, i am trying to make a fully editable dataGrid and was using the "Top Ten Questions about the DataGrid Control" article in the MSDN Library as a guide. The following is my current vb code. I ran...
5
by: daniel.hedz | last post by:
I am generating a usercontrol dynamically successfully, but when I try to find that usercontrol I get a type mismatch. This is what I am doing: //Loading my usercontrol...
14
by: =?Utf-8?B?QWxleCBNYWdoZW4=?= | last post by:
Hi. I have created a UserControl ("MyUC"). I've put a bunch of instances of that control on a Page ("Defaul.aspx"). The control works fine. Now, I want to be able to use "FindControl()" from...
7
by: AAaron123 | last post by:
Me.FindControl("MissionScheduleID"), below returns null. Do you know what I'm doing wrong? Thanks ***In my .aspx file I have: asp:Content ID="Content3"...
9
by: AAaron123 | last post by:
I'm this far in determining the correct code to find a textbox I need to set. ...
2
by: pankajsingh5k | last post by:
Dear All, Please help me... I had read an article to lazy load a tab in a tabcontainer using an update panel on http://mattberseth.com/blog/2007/07/how_to_lazyload_tabpanels_with.html ...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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...
1
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...
0
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,...
1
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...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.