主题:当动态向添加Table中的行时,为什么我只能添加一行?添加第二行时第一行就消失了,这个怎么解决阿?
wangpeng527
[专家分:0] 发布于 2006-04-14 16:05:00
如题,当动态向添加Table中的行时,为什么我只能添加一行?添加第二行时第一行就消失了,这个怎么解决阿?谢谢!
回复列表 (共4个回复)
沙发
guangmingshizhe [专家分:4930] 发布于 2006-04-14 23:58:00
把你代码贴出来看看啊
用tbody然后添加listrow吧,这样比较好用
板凳
wangpeng527 [专家分:0] 发布于 2006-04-17 08:40:00
private void Button6_Click(object sender, System.EventArgs e)//增加行
{
TableRow hrow=new TableRow();
TableCell hcell=new TableCell();
hcell.Text=DropDownList7.SelectedValue;
hrow.Cells.Add(hcell);
hcell=new TableCell();
hcell.Text=DropDownList8.SelectedValue;
hrow.Cells.Add(hcell);
hcell=new TableCell();
hcell.Text=TextBox1.Text.Trim();
hrow.Cells.Add(hcell);
hcell=new TableCell();
hcell.Text=DropDownList9.SelectedValue;
hrow.Cells.Add(hcell);
Table1.Rows.Add(hrow);
}
3 楼
leek9d [专家分:30] 发布于 2006-04-21 14:03:00
DataTable dt = new DataTable("t");
DataRow dr = dt.NewRow();
dt.Rows.Add(dr);
试试
4 楼
qiqibibi [专家分:0] 发布于 2006-04-28 14:50:00
如果你不怕麻烦又怕出错的话,用最老实的办法:
private void Button6_Click(object sender, System.EventArgs e)//增加行
{
TableRow hrow=new TableRow();
TableCell hcell=new TableCell();
hcell.Text=DropDownList7.SelectedValue;
hrow.Cells.Add(hcell);
table1.rows.ass(hrow);
hrow=new tablerow();
hcell=new TableCell();
hcell.Text=DropDownList8.SelectedValue;
hrow.Cells.Add(hcell);
table1.rows.add(hrow);
hrow=new tablerow()
hcell=new TableCell();
hcell.Text=TextBox1.Text.Trim();
hrow.Cells.Add(hcell);
table.rows.add(hrow);
hrow=new tablerow();
hcell=new TableCell();
hcell.Text=DropDownList9.SelectedValue;
hrow.Cells.Add(hcell);
Table1.Rows.Add(hrow);
}
可以试试看吧,虽然看起来有点麻烦但是有规律,不容易出错
我来回复