dim htmltr as tablerow
dim htmltd as tablecell
dim lblUser as new label
dim txtUser as new textboxhtmltr=new tablerow
htmltd=new tablecell
htmltd.controls.add(lblUser)
htmltd.controls.add(txtUser)
htmltr.cell.add(htmltd)
Table.row.add(htmltr)

解决方案 »

  1.   

    int numrows = table.Rows.Count;
    for (int j=0; j<numrows; j++) 
    {          
     TableRow r = new TableRow();
     TableCell c1 = new TableCell();
     TableCell c2 = new TableCell();
     Label1.Text = table.Rows[j]["Name"].ToString();
     c1.Controls.Add(Label1);
     c2.Controls.Add(TextBox1);
     r.Cells.Add(c1);
    }我想知道怎么访问TextBox1的内容,如果我用 Table1.Rows[i].Cells[1].ToString()是不行的,多谢
    r.Cells.Add(c2);
    Table1.Rows.Add(r);
    }
      

  2.   

    你添加的时候定义一个ID,比如Label Label1 = new Label()
    Label1.ID = "MyLabel"
    Table1.Controls.Add(Label1);//回发时先要执行上面的代码,否则会找不到
    string getValue = ( ( Label )Table1.FindControl("MyLabel") ).Text;