62,041
社区成员
发帖
与我相关
我的任务
分享
TableRow r;
TableCell c;
for (i = 0; i < numrows; i++)
{
r = new TableRow();
for (j = 0; j < numcells; j++)
{
System.Web.UI.WebControls.Button bt;
bt = new System.Web.UI.WebControls.Button();
bt.Width = 30;
// 获取该显示的数字
int z = i * 7 + j; // 显示的位置
bt.Text= z > x && z <= x + num ? (z - x).ToString() : string.Empty;
if (bt.Text == string.Empty)
bt.Visible = false;
// 这里尝试给每个按钮添加一个点击事件 但是不响应
bt.Attributes["onclick"] = "bt_click";
bt.Click += new EventHandler(this.bt_click);
// ...............
c = new TableCell();
c.Controls.Add(bt);
r.Cells.Add(c);
}
TIME.Rows.Add(r);
}
void bt_click(Object sender,EventArgs e)
{
.....
}