我有一个FormView,试图根据该视图中的一个文本框的输入触发一个操作。我打算完成的是将控制抛到‘受保护的空ARSControlNumTextBox_TextChanged’部分后面的代码,其中我想将TextBox的内容填充到一个标签(CurrentCtrl)中。
我已经设置了一个断点来观察正在发生的事情,因为我没有看到预期的结果。下面是所讨论的代码:
protected void ARSControlNumTextBox_TextChanged(object sender, EventArgs e)
{
TextBox thecontrol = (TextBox)ARS30InputFrm.Row.FindControl("ARSControlNum");
if (thecontrol != null)
CurrentCtrl.Text = thecontrol.Text;
}所发生的情况是跳过了值分配。所以看来“控制”是无效的!这并不能说明问题。
下面是Formview的一个缩写部分,这样您就可以看到我从哪里得到的值:
<asp:FormView runat="server" ID="ARS30InputFrm" DataSourceID="ARFS" DefaultMode="Insert">
<InsertItemTemplate>
Control #:
<asp:TextBox Text='<%# Bind("ARSControlNum") %>' runat="server" AutoPostBack="true" OnTextChanged="ARSControlNumTextBox_TextChanged" ID="ARSControlNumTextBox" />
<asp:LinkButton runat="server" Text="Insert" CommandName="Insert" ID="InsertButton" CausesValidation="True" /> <asp:LinkButton runat="server" Text="Cancel" CommandName="Cancel" ID="InsertCancelButton" CausesValidation="False" />
</InsertItemTemplate>
</asp:FormView>以及标签,它是它从TextBox得到的数据的最终目标:
Current Control Edit: <asp:Label ID="CurrentCtrl" runat="server" ></asp:Label>我看不出我在这里做错了什么。其他人看到了吗?如果是这样的话,我肯定会感激一些眼睛对目标,因为这是把我从弯曲的一端!你好肯..。
发布于 2017-02-14 20:23:20
难道不是吗
protected void ARSControlNumTextBox_TextChanged(object sender, EventArgs e)
{
TextBox thecontrol = (TextBox)ARS30InputFrm.Row.FindControl("ARSControlNumTextBox");
if (thecontrol != null)
CurrentCtrl.Text = thecontrol.Text;
}https://stackoverflow.com/questions/42235385
复制相似问题