1. 在GridView中添加一列按钮
在html文件的GridView中添加模版列,代码如下:
CommandName="Auditing"
CommandArgument="<%# ((GridViewRow) Container).RowIndex %>"
Text="审核" />
则,回到设计视图,会发现多了一列按钮。
2. 添加按钮事件
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
Int32 i = Convert.ToInt32(e.CommandArgument.ToString());//得到行号
if (e.CommandName == "Auditing")
{
Response.Write("<script>alert('操作成功')</script>");
}
}