我动态创建了一个 gridview 并添加了 AutoGenerateEditButton = true; 属性,我看到它在将表格加载到gridview时将编辑链接添加到所有字段。但是当我单击编辑按钮时,除了回发之外,什么都没有发生。我究竟做错了什么?
GridView gridData = new GridView();
gridData.ID = "test";
gridData.AutoGenerateEditButton = true;
gridData.RowEditing += (sender, e) => grid_RowEditing(tbl, e, sender);
gridData.DataSource = tbl;
gridData.DataBind();
protected void grid_RowEditing(DataTable tbl, GridViewEditEventArgs e, object sender)
{
((GridView)sender).EditIndex = e.NewEditIndex;
// call your databinding method here
((GridView)sender).DataSource = tbl ;
((GridView)sender).DataBind();
}