views:

28

answers:

1

I have to add a textbox inside a form that is composed of a lot of textboxes, and one button at the end. It has a datasource, all data is loaded in formload, and the button updates the values of the textboxes. The thing is: this particular textbox won't be in the datasource, I want to get this from the web.config, and I've already managed to change the web.config in other page, but in this case, the textbox ID won't appear in intellisense in the code-behind of the page itself, so I figured it's unaccessible to anything besides the pure binding of the form.

<asp:FormView>
<EditItemTemplate>
    <asp:TextBox ID="id" runat="server" Text='<%# bind("field") %>'/>
    <asp:TextBox ID="id2" runat="server" Text='<%# bind("field2") %>'/>
    <asp:TextBox ID="id3" runat="server" Text='<%# bind("field3") %>'/>

    <asp:TextBox ID="THIS_ONE" runat="server"></asp:TextBox> <!--HERE-->

    <asp:Button ID="UpdateButton" runat="server" SkinID="UpdateButton" CommandName="Update"/>

</EditItemTemplate>
</asp:FormView>

Above, I have an unaccessible textbox.

<asp:FormView>
<EditItemTemplate>
    <asp:TextBox ID="id" runat="server" Text='<%# bind("field") %>'/>
    <asp:TextBox ID="id2" runat="server" Text='<%# bind("field2") %>'/>
    <asp:TextBox ID="id3" runat="server" Text='<%# bind("field3") %>'/>

    <asp:Button ID="UpdateButton" runat="server" SkinID="UpdateButton" CommandName="Update"/>

</EditItemTemplate>
</asp:FormView>

    <asp:TextBox ID="THIS_ONE" runat="server"></asp:TextBox><!--HERE-->

Above, I have an accessible textbox, but BELOW the update button.

I've already tried closing EditItemTemplate before the textbox and re-opening it afterwards. Doesn't work.

I could of course put it below the button, below where the form ends, then they wouldn't be part of the form, and that would work, but what if I want the textboxes ABOVE the button ? I want accessible unbinded textboxes inside an ASP.NET formview. Is that possible ?

ps.: I know the implications of messing with web.config in run-time and I know that this doesn't seem well planned, but I didn't say some details that don't matter for this question.

+1  A: 

Hey,

If your issue trying to access the textbox? You can use FormView1.FindControl() to obtain a reference to the control within the formview...

Brian
It worked! thank you!
MarceloRamires