DemHere是我的textarea控件:
<textarea id="Physical_DemandsTextBox" runat="server" cols="35" rows="6" value='<%# Bind("Physical_Demands") %>' />
这是我的逻辑,适用于其他asp:TextBox
控件
if (FormView1.CurrentMode == FormViewMode.Insert)
{
TextBox txtPhyDem = FormView1.FindControl("Physical_DemandsTextBox") as TextBox;
}
if (txtPhyDem != null)
{
txtPhyDem.Text = "Failed Test of the Testing Testers.";
}
当我在插入模式下运行应用程序时,文本区域为空白。我该如何解决这个问题?
答案 0 :(得分:1)
您只需要使用文本框控件替换textarea,如下所示:
<asp:TextBox ID="Physical_DemandsTextBox"
TextMode="MultiLine" Rows="6" Columns="35"
runat="server"
Text='<%# Bind("Physical_Demands") %>'></asp:TextBox>
答案 1 :(得分:0)
您可以使用Body
属性作为示例:
if (FormView1.CurrentMode == FormViewMode.Insert)
{
Physical_DemandsTextBox.Body = "Failed Test of the Testing Testers.";
}
但你也可以直接使用asp.net控件,对于样本,在webform中更好:
<asp:TextBox id="Physical_DemandsTextBox" runat="server"
TextMode="Multiline"
Columns="35"
Rows="6" />
和代码behine:
if (FormView1.CurrentMode == FormViewMode.Insert)
{
Physical_DemandsTextBox.Text = "Failed Test of the Testing Testers.";
}