Find Control in user control

C

Chris

I have a user control which is dynamically loaded into a placeholder. I have
a formview in the user control

In the page load event of the user control I wand to find a dropdown in the
formview. I always get a null reference. It's really late and I guess it is
something obvious but I can't think. Regards, Chris.

Dim drp As New DropDownList

drp = CType(fvwAcknowlegement.FindControl("drpUploadType"), DropDownList)

drp.Visible = true
 
?

=?ISO-8859-1?Q?G=F6ran_Andersson?=

Chris said:
I have a user control which is dynamically loaded into a placeholder. I have
a formview in the user control

In the page load event of the user control I wand to find a dropdown in the
formview. I always get a null reference. It's really late and I guess it is
something obvious but I can't think. Regards, Chris.

Dim drp As New DropDownList

drp = CType(fvwAcknowlegement.FindControl("drpUploadType"), DropDownList)

drp.Visible = true

You can't find any form fields in the FormView, as it doesn't directly
contain any form fields. It contains a collection of items, and each
item has it's own set of form fields. You first have to access the
specific item you want, then you can access it's fields.
 
C

Chris

This code works when I put it in the item_created event of the formview.
Moreover this code works, in the page load of the control, when I manually
add the control to the page. It only causes a problem when the control is
added dyanically and I add the code to the page load event of the user
control. I don't understand why the controls seem to be added in a different
order when the user control is added dynamically. It's sort of working but I
would like to know why. Regards, Chris.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,754
Messages
2,569,525
Members
44,997
Latest member
mileyka

Latest Threads

Top