2013-12-18 46 views
1

DemHere是我的textarea的控制:如何設置文本的textarea在FormView控件插入模式

<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

在哪個頁面事件中您正在執行此操作? –

回答

0

你可以使用Body屬性,樣品:

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

但你也可以直接使用的asp.net控制什麼是更好,樣品,在網頁表單:

<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."; 
} 
1

您只需要將文本框控件替換爲textarea作爲f ollow:

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