<style type="text/css">
tr
{
css : expression(onmouseover=function() {bgColor=this.style.backgroundColor;this.style.backgroundColor="violet";this.style.cursor="hand";},
onmouseout=function() {this.style.backgroundColor=bgColor;})
}
</style>
protected void gridViewXML_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes.Add("onmouseover", "bgColor=this.style.backgroundColor;this.style.backgroundColor='violet';this.style.cursor='hand';");
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=bgColor");
string value = string.Format("return confirm('确实要删除编号“{0}”吗?');", e.Row.Cells[1].Text);
e.Row.Cells[delIndex].Attributes.Add("OnClick", value);
}
}
本文介绍如何在ASP.NET中使用GridView控件实现鼠标悬停时高亮显示行,并为删除操作添加确认提示。通过添加JavaScript代码实现交互效果,确保用户在进行删除操作前得到确认。

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



