在TABLE中加一个BUTTON???
我是这样写的
TableCell cell;
TableRow row ;
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
row = new TableRow();
for (int j = 0; j < ds.Tables[0].Columns.Count; j++)
{
Button aa = new Button();
aa.Text = "ddd ";
cell = new TableCell();
cell.Controls.Add(aa)
cell.Text =ds.Tables[0].Rows[i][j].ToString();
row.Cells.Add(cell);
}
this.Table_infor.Rows.Add(row);
}
但是不行呀?
------解决方案-------------------- <%@ Page Language= "C# " %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN " "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<script runat= "server ">
protected void Page_Load(object sender, EventArgs e) {
for (int i = 0; i < 10; i++) {
HtmlTableRow tr = new HtmlTableRow();
for (int j = 0; j < 2; j++) {
HtmlTableCell td = new HtmlTableCell();
Button btn = new Button();
btn.Text = String.Format( "[{0}][{1}] ", i, j);
td.Controls.Add(btn);
tr.Cells.Add(td);
}
Table_infor.Rows.Add(tr);
}
for (int i = 0; i < 10; i++)
{
TableRow tr = new TableRow();
for (int j = 0; j < 2; j++)
{
TableCell td = new TableCell();
Button btn = new Button();
btn.Text = String.Format( "[{0}][{1}] ", i, j);
td.Controls.Add(btn);
tr.Cells.Add(td);
}
Table_infor_2.Rows.Add(tr);
}