views:

216

answers:

2

Hi... I have a web form which contains a formview(fv). how can I find a linkbutton within it (lnkbtnEdit) in order to write code for changing mode?

thank you

A: 

Your question is quite vague so I'll try to make my answer as general as possible.

Container controls in ASP.NET provide a FindControl method which uses Reflection to locate the control with the specified name in their child controls. Using this method is the accepted method to locate controls within a Page or Panel or Templated control like the FormView.

If you want to avoid Reflection, you can also locate the control manually if you know the index of the control in the heirarchy.

Also, it is very helpful to know the point of time at which you need to access this control, because it is quite possible that the child control has not been created yet.(See my comment to your question.)

Cerebrus
A: 

Cerebus, Thanks for your reply.... but it seems that I can not select the lnkbtnEdit within the fv. If I could, then simply selected it in design view, and in event section of property window, I could write a handler for clicking it....

odiseh