我在cs文件中创建了一个按钮,其代码如下所示,并尝试触发表格内按钮的事件处理程序。但是,它不起作用。我可以知道该怎么办?
protected void feesinfo_Click(object sender, EventArgs e)
{
//Hidden field for checking in .aspx file
ClientScript.RegisterHiddenField("typeButton", "FEE_INFO");
System.Diagnostics.Debug.WriteLine("School Fees Details");
Table tbl = new Table();
for (int i = 0; i < 5; i++)
{
TableRow tRow = new TableRow();
Table1.Rows.Add(tRow);
for (int j = 1; j <= 6; j++)
{
TableCell tCell = new TableCell();
if (j == 4)
{
Button btn = new Button();
btn.CssClass = "btn btn-success";
btn.ID = "btndetails";
btn.Text = "400";
tCell.Controls.Add(btn);
btn.Click += new EventHandler(btnClick);
}
else
{
tCell.Text = "Row " + i + ", Cell " + j;
}
tRow.Cells.Add(tCell);
}
}
}
protected void btnClick(object sender, EventArgs e)
{
ClientScript.RegisterHiddenField("typeButton", "Details");
System.Diagnostics.Debug.WriteLine("School Fees Details");
mpe.Show();
}