简体   繁体   English

如何在插入模式下的formview中将文本设置为textarea

[英]How do I set text to textarea in formview in insert mode

DemHere is my textarea control: DemHere是我的textarea控件:

<textarea id="Physical_DemandsTextBox" runat="server" cols="35" rows="6" value='<%# Bind("Physical_Demands") %>' />

Here is my logic that works with the other asp:TextBox controls 这是我与其他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.";
   }         

When I run the application on insert mode the text area is blank. 在插入模式下运行应用程序时,文本区域为空白。 How do I fix this? 我该如何解决?

You Just need to replace textarea with textbox control as follow: 您只需要用文本框控件替换textarea,如下所示:

    <asp:TextBox ID="Physical_DemandsTextBox" 
        TextMode="MultiLine" Rows="6" Columns="35" 
        runat="server" 
        Text='<%# Bind("Physical_Demands") %>'></asp:TextBox>

You could use the Body property, for sample: 您可以使用Body属性作为示例:

if (FormView1.CurrentMode == FormViewMode.Insert)
{
   Physical_DemandsTextBox.Body = "Failed Test of the Testing Testers.";
}

but you also could use directly the asp.net control what is better, for sample, in webform: 但您也可以直接使用asp.net控件,以Webform为例更好。

<asp:TextBox id="Physical_DemandsTextBox" runat="server" 
                                          TextMode="Multiline" 
                                          Columns="35" 
                                          Rows="6" />

and code behine: 和代码behine:

if (FormView1.CurrentMode == FormViewMode.Insert)
{
    Physical_DemandsTextBox.Text = "Failed Test of the Testing Testers.";
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM