How do I reference a child control withing main form?

G

Guest

Hello,

I have DetailsView control called "EmployeeDetails" with a bunch of fields,
one of thos is button called "btnAddEmployee" inside ItemTemplate . How do I
get access to properties of that button from within a main page?
Page.FindControl("btnAddEmployee") does not work,
EmployeeDetails.FindControl("btnAddEmployee") also returns null. I'm trying
to set those values in Page_PreRender event.
 
J

Josh

I have DetailsView control called "EmployeeDetails" with a bunch of
fields,
one of thos is button called "btnAddEmployee" inside ItemTemplate . How
do I
get access to properties of that button from within a main page?
Page.FindControl("btnAddEmployee") does not work,
EmployeeDetails.FindControl("btnAddEmployee") also returns null. I'm
trying
to set those values in Page_PreRender event.

Its normal practice to access those controls on postback or in itemdatabound
event.

But if you really must get to it from the page you should be able to access
the Items collection, each item has a FindControl.
 
G

Guest

Which Items I need to scroll through to find control? EmployeeDetails has
only 1 child control in DataBound() event even though I can see DetailsView
rendered properly on a page with all the fields in place.
 

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

No members online now.

Forum statistics

Threads
473,773
Messages
2,569,594
Members
45,122
Latest member
VinayKumarNevatia_
Top