在表格的一行中填写输入文本 [英] fill a Input text in a row in a table

查看:75
本文介绍了在表格的一行中填写输入文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在表格的一行中填充输入文本.

how i can fill a Input text in a row in a table.

推荐答案

纯HTML?可能是这样的:

Pure HTML? Something like this, perhaps:

<table>
    <tr>
        <td>
            <form method="POST" action="">
                <input type="submit" value="Submit" name="sub">
                <input type="reset" value="Reset" name="rst">
            </form>
        </td>
    </tr>
</table>



OP:我看到这已经被否决了,但是目前,答案是对您的问题的最恰当的回答,因为它的措辞很明确.



OP: I see that this has been downvoted, but at the moment, the answer is the most appropriate response to your question as it''s curently phrased.


您可以尝试一下. (我不确定,但信息不足)
希望对您有帮助

假设您有一个像这样的表格2个表格和一个按钮

You could try this. (I am not sure though, not enough info)
hope it helps

assume you have a form like this 2 tables and a button

<form id="form1" runat="server">
  <div>
  </div>
  <asp:Table ID="Table1" runat="server" Height="185px" Width="341px">
  <asp:TableRow>
  <asp:TableCell ID="r1">
      <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox></asp:TableCell>
  </asp:TableRow>
  <asp:TableRow ID="r2">
  <asp:TableCell ID="txtcell">
      <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox></asp:TableCell>
  </asp:TableRow>
  </asp:Table>

<hr />


  <table id="Table2" runat="server">
  <tr>
  <td> <asp:TextBox ID="TextBox3" runat="server"></asp:TextBox></asp:TableCell></td>
  </tr>
  <tr>
  <td> <asp:TextBox ID="TextBox4" runat="server"></asp:TextBox></asp:TableCell></td>
  </tr>
  </table>

  <br />
  <asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" />
  </form>










将此放在您的代码后面

受保护的void Button1_Click(对象发送者,EventArgs e)
{TextBox txt =(TextBox)FindControlRecursive(Table1,"TextBox1");
TextBox txt2 =(TextBox)FindControlRecursive(Table1,"TextBox2");
TextBox txt3 =(TextBox)FindControlRecursive(Table2,"TextBox3");
TextBox txt4 =(TextBox)FindControlRecursive(Table2,"TextBox4");
txt.Text ="yourvalue";
txt2.Text ="yourvalue2";
txt3.Text ="yourvalue3";
txt4.Text ="yourvalue4";
}


公共控件FindControlRecursive(控件根,字符串ID)
{
如果(Root.ID == Id)
返回根;
foreach(Root.Controls中的Control Ctl)
{
控件FoundCtl = FindControlRecursive(Ctl,Id);
如果(FoundCtl!= null)
返回FoundCtl;
}
返回null;
}










put this in your code behind

protected void Button1_Click(object sender, EventArgs e)
{ TextBox txt = (TextBox)FindControlRecursive(Table1, "TextBox1");
TextBox txt2 = (TextBox)FindControlRecursive(Table1, "TextBox2");
TextBox txt3 = (TextBox)FindControlRecursive(Table2, "TextBox3");
TextBox txt4 = (TextBox)FindControlRecursive(Table2, "TextBox4");
txt.Text = "yourvalue";
txt2.Text = "yourvalue2";
txt3.Text = "yourvalue3";
txt4.Text = "yourvalue4";
}


public Control FindControlRecursive(Control Root, string Id)
{
if (Root.ID == Id)
return Root;
foreach (Control Ctl in Root.Controls)
{
Control FoundCtl = FindControlRecursive(Ctl, Id);
if (FoundCtl != null)
return FoundCtl;
}
return null;
}


这篇关于在表格的一行中填写输入文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆