Ana,

the label will not exist in the page if the content was not bindable yet.

I mean, the control will only be rendered if there is a datasource linked on
it and it you've invoked the myFormView.DataBind() method.

Another thing, if you place this control into <InsertItemTemplate> tags, it
will only be visible when the FormView is in insert mode.
I don't know if you want that behavior, but, the correct would be
<ItemTemplate> tags instead.

Hope you understood.

On Mon, Oct 19, 2009 at 8:49 PM, Ana <[email protected]> wrote:

>
> Hi,
>
> My question is quite simple but I can't find the solution.
> I have a FormView inside a div and, inside the formview, I have an
> InsertItemTemplate. In this InsertItemTemplate, I have a Label that I
> need to access in the code behind. My code is as follows:
>
> <div id="myDiv" runat="server">
>        <asp:FormView ID="myFormView" runat="server"
> SkinID="DetailsFormview">
>            <InsertItemTemplate>
>                <table width="400">
>                    <tr>
>                        <td align="right">
>                            <b>Label: </b>
>                        </td>
>                        <td align="left">
>                            <asp:Label ID="myLabel" runat="server" />
>                        </td>
>                    </tr>
>                </table>
>            </InsertItemTemplate>
>        </asp:FormView>
> </div>
>
> I tried the following:
>
> Dim myLabel As Label = CType(myFormView.FindControl("myLabel"), Label)
>
> But myLabel is always Nothing :(
>
> How do I get the control then?
>
> Thanks a lot,
>
> Ana




-- 
Atenciosamente,
Paulo Roberto S. Pellucci

Reply via email to