By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,685 Members | 1,243 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,685 IT Pros & Developers. It's quick & easy.

Find Control in user control

P: n/a
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

Jun 4 '07 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Chris wrote:
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.

--
Göran Andersson
_____
http://www.guffa.com
Jun 5 '07 #2

P: n/a
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.

"Göran Andersson" <gu***@guffa.comwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
Chris wrote:
>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.

--
Göran Andersson
_____
http://www.guffa.com

Jun 5 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.