我必须在由许多文本框组成的表单中添加一个文本框,最后有一个按钮。它有一个数据源,所有数据都在 formload 中加载,并且按钮更新文本框的值。问题是:这个特定的文本框不会在数据源中,我想从 web.config 中获取它,并且我已经设法更改其他页面中的 web.config,但在这种情况下,文本框 ID不会出现在页面本身的代码隐藏中的智能感知中,所以我认为除了表单的纯绑定之外,任何东西都无法访问它。
<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>
上面,我有一个无法访问的文本框。
<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-->
上面,我有一个可访问的文本框,但在更新按钮下方。
我已经尝试在文本框之前关闭 EditItemTemplate 并在之后重新打开它。不工作。
我当然可以将它放在按钮下方,在表单结束的下方,那么它们就不会成为表单的一部分,这会起作用,但是如果我想要按钮上方的文本框怎么办?我想要在 ASP.NET formview 中访问未绑定的文本框。那可能吗 ?
ps.:我知道在运行时搞乱 web.config 的含义,我知道这似乎没有很好的计划,但我没有说一些对这个问题无关紧要的细节。