1.删除确定提示
在行绑定事件中,先判断是否是数据行,再判断数据行状态是否正常或是交替行,
把当前行删除列隐式转为LinkButton,并对其属性添加确认框
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
if (e.Row.RowIndex != -1)//如果当前行不等于-1,编行号
{
int hanghao = e.Row.RowIndex + 1;
e.Row.Cells[0].Text = hanghao.ToString();//绑定行第0列填编号
}
if (e.Row.RowState == DataControlRowState.Normal || e.Row.RowState == DataControlRowState.Alternate)
{
((LinkButton )(e.Row.Cells[11].Controls [0])).Attributes.Add("onclick", "javascript:return confirm('你确定要删除此记录吗?')");
//删除确认框
}
}
}