Skullomania
Skullomania

Reputation: 2215

How do I set text to textarea in formview in insert mode

DemHere is my textarea control:

<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

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?

Upvotes: 1

Views: 541

Answers (2)

Bhavesh Kachhadiya
Bhavesh Kachhadiya

Reputation: 3962

You Just need to replace textarea with textbox control as follow:

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

Upvotes: 1

Felipe Oriani
Felipe Oriani

Reputation: 38608

You could use the Body property, for sample:

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:TextBox id="Physical_DemandsTextBox" runat="server" 
                                          TextMode="Multiline" 
                                          Columns="35" 
                                          Rows="6" />

and code behine:

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

Upvotes: 0

Related Questions