protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Cells[5].Attributes.Add("onclick", "return confirm('你确认要编辑吗?')");
}
}
本文介绍了一个ASP.NET中GridView控件使用示例,通过RowDataBound事件为每一行的特定单元格添加onclick属性,实现点击时弹出确认对话框的功能。
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Cells[5].Attributes.Add("onclick", "return confirm('你确认要编辑吗?')");
}
}

被折叠的 条评论
为什么被折叠?