views:

259

answers:

2

What is the trick to get the controls inside the FormView. I was getting them with FindControl() but, now i cant get access on them. Example: i have some ImageButton on the FooterTemplate, great i can get those smoothly, when it comes to the controls inside the FormView!!! null every control. Do you think i should name them differently in every template? This gets me thinking about the table causing this noise!

I'm using the DataBound Event and checking for specific Mode! Any ideas? Thank you.

[UPDATED]

This is working

            if (this.kataSistimataFormView.CurrentMode == FormViewMode.Edit)
        {
            ImageButton update = (ImageButton)this.kataSistimataFormView.FindControl("btnUpdate");
            update.Visible = true;

But this for some reason no

        CheckBox chkBoxPaidoi = kataSistimataFormView.FindControl("chkBoxPaidoi") as CheckBox;
A: 

FindControl is not recursive. What I mean is that it will only find controls that are within the child controls of the control you are searching - it will not search any child controls of the child controls

If you have placed the control you previously were looking for within another control then you will have to either search within that new control or, if you still want to use kataSistimataFormView as the parent control, you may have to use a recursive search.

Google for "findcontrol recursive" there are some good examples that you can probably just cut-and-paste.

mlennox
I guess this means as i was suspected, since they are now into the Html Table rows and columns i must get the table and then search on it, and this if it isn't some noise :)
A: 

As it seems this was caused because of the same naming ID's on various templates, Insert,Edit,Item. Even this is supported by the compiler, has problem when you are going for them programmaticaly later.

Thank you all.