本文介绍了表控件中的动态添加表行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经创建了一个表,并且希望在该表中动态添加行.

I have created a table and I want to add row dynamically in this table.

<asp:Table ID="Table1" runat="server" Width="36px">
<asp:Table>



代码文件:



Code file:

protected void Button1_Click(object sender, EventArgs e)
    {
        TableRow row = new TableRow();
        TableCell cell1 = new TableCell();
        TableCell cell2 = new TableCell();
        TextBox txtt = new TextBox();

        txtt.ID = "txt";

        DropDownList dpn_phone = new DropDownList();
        dpn_phone.Items.Add("Home");
        dpn_phone.Items.Add("Work");
        dpn_phone.Items.Add("Mobile");
        dpn_phone.ID = "pho";

        cell1.Controls.Add(txtt);
        cell2.Controls.Add(dpn_phone);
        row.Cells.Add(cell1);
        row.Cells.Add(cell2);

        Table1.Rows.Add(row);
        ph.Controls.Add(t);
    }



但是,当发生任何往返行程时,Table1行将被删除



But when any round trip is happening then Table1 rows are deleting

推荐答案


这篇关于表控件中的动态添加表行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-27 12:52