我正在gridview
动态创建...现在我想在其中添加一些按钮并添加它们的相关 rowCommand 事件。请帮我这样做。这就是我在代码中动态创建 GridView 的方式
for (int i = 0; i < dtEmployees.Rows.Count; i++)
{
TableRow tr = new TableRow();
TableCell tc = new TableCell();
GridView gv = new GridView();
gv.ID = "gv" + dtTasks.Rows[i]["TaskID"].ToString() + dtEmployees.Rows[i]["EmpID"].ToString();
DataTable dt = dtTasks.Clone();
foreach (DataRow dr in dtTasks.Rows)
{
if (dr["EmpID"].ToString() == dtEmployees.Rows[i]["EmpID"].ToString())
{
dt.Rows.Add(dr.ItemArray);
}
}
gv.DataSource = dt;
gv.DataBind();
tc.Controls.Add(gv);
tr.Cells.Add(tc);
tblMain.Rows.Add(tr);
}