很简单的只要在你的GridView的RowDataBound事件中加入以下代码,其中LinkButton为GridView数据行中的删除按钮
- protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
- {
- if (e.Row.RowType == DataControlRowType.DataRow)
- {
- //删除前弹框提示
- LinkButton b = e.Row.FindControl("LinkButton1") as LinkButton;
- b.Attributes.Add("onclick", "return confirm('确定要删除吗?');");
- //高亮显示
- e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor;this.style.backgroundColor='#66ff99'");
- e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c");
- }
- }