日期:2014-05-17 浏览次数:20455 次
protected void Page_Load(object sender, EventArgs e)
{
Table tb = new Table();
for (int i = 0; i < 20; i++)
{
TableRow row = new TableRow();
for (int j = 0; j < 20; j++)
{
TableCell cell = new TableCell();
Button bt = new Button();
bt.ID = string.Format("bt{0}_{1}", i, j);
bt.Text = string.Format("{0}行{1}列", i, j);
bt.Click += new EventHandler(bt_Click);
cell.Controls.Add(bt);
row.Cells.Add(cell);
}
tb.Rows.Add(row);
}
this.Controls.Add(tb);
}
void bt_Click(object sender, EventArgs e)
{
Button bt = sender as Button;
string[] tmp = bt.ID.Replace("bt", string.Empty).Split('_');
&nb