开发者

Textbox control in ASP.NET not to be part of a formview

开发者 https://www.devze.com 2022-12-25 21:30 出处:网络
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 t

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开发者_StackOverflow don't matter for this question.


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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号