【问题标题】:Get text from textbox that inside asp:FormView从 asp:FormView 内的文本框中获取文本
【发布时间】:2015-12-30 11:26:33
【问题描述】:

您好,我只需要从 texbox 中获取文本,但我的文本框在 asp:FormView 内部,我得到了它。我可以使用并获取值的所有文本框,但不是所有在 asp:FormView 中的文本框。它说元素不会在内容中退出

我在这里缺少什么?

我的html。

    <asp:Content ID="Content1" runat="server">

   <input   id="txt_Out"   runat="server" tabindex="1" value="trst">

  <asp:FormView ID="MainFormTemplate" runat="server">
     <ItemTemplate>
       <li class="li_result" runat="server">
      <input id="txt_In"   runat="server" tabindex="1" value="test">
       </li>
    </ItemTemplate>
      </asp:FormView>
    </<asp:Content>


    Server

 public void btn_Update_Click(object sender, EventArgs e)
  {
    string text=txt_Out.Value;//Good
    string text1=txt_In//error Dont exist
    }

【问题讨论】:

    标签: c# asp.net .net


    【解决方案1】:

    它在FormView里面,所以你不能直接访问它。你需要在FormView控件里面找到它。

    (Textbox)MainFormTemplate.FindControl("txt_In");
    

    【讨论】:

      猜你喜欢
      • 2021-08-31
      • 1970-01-01
      • 2013-08-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-08-08
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多