日期:2014-05-19  浏览次数:20425 次

如何在.NET2005 中实现数据的高亮显示
以前在2003中实现了数据的高亮显示,代码是这样的

if   (e.Item.ItemType   ==   ListItemType.Item   e.Item.ItemType   ==   ListItemType.AlternatingItem)
{
e.Item.Attributes.Add( "onmouseover ", "this.style.backgroundColor=’#99cc00’;
   this.style.color=’buttontext’;this.style.cursor=’default’; ");
e.Item.Attributes.Add( "onmouseout ", "this.style.backgroundColor=’’;this.style.color=’’; ");
}

现在刚学2005         能不能帮忙改为在2005中运行的代码,谢谢了

------解决方案--------------------
双击GridView的OnRowDataBound事件;
在后台的GridView1_RowDataBound()方法添加代码,最后代码如下所示:
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Item.Attributes.Add( "onmouseover ", "this.style.backgroundColor=’#99cc00’;
   this.style.color=’buttontext’;this.style.cursor=’default’; ");
e.Item.Attributes.Add( "onmouseout ", "this.style.backgroundColor=’’;this.style.color=’’; ");
}

}

------解决方案--------------------
道理一样啊 不过你这么做好象有点笨
你可以写一个JS
function doit(object)
{
object.onmouseover= " ";
object.onmouseout= " ";
}
直接调用就好了啊
------解决方案--------------------
e.Row.Attributes.Add
主要就是通过这个在行中加上css属性