1.Gridview中实现行变色 :
//****在后台RowDataBound事件进行处理
foreach (GridViewRow gdVRow in GView.Rows)
...{
gdVRow.Attributes.Add("onclick", "this.className='onclickbackgroundcolor'");


//****获取处理按钮
LKBtnDelete = (LinkButton)gdVRow.FindControl("LKBtnDelete");
//****邦定javascript
LKBtnDelete.Attributes.Add("onclick","javascript:if(confirm('请确认是否删除记录为[" + e.Row.Cells[2].Text + "]记录!')==false) return false;");
}
//****这里高用一个CSS函数
foreach (GridViewRow gvRow in gridview1.Rows)
...{
gdVRow.Attributes.Add("onmouseover", "this.backgroundColor='#ffffff'");
gdVRow.Attributes.Add("onmouseout", "this.backgroundColor='#ffffff'");
}
本文介绍如何在ASP.NET的Gridview控件中实现行点击变色及删除确认功能,通过绑定JavaScript和设置CSS样式来增强用户体验。
797

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



