首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

怎么在.NET2005 中实现数据的高亮显示

2012-01-30 
如何在.NET2005 中实现数据的高亮显示以前在2003中实现了数据的高亮显示,代码是这样的if(e.Item.ItemType

如何在.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属性

热点排行