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

怎么在gridview中实现单击选择的行改变颜色

2012-04-07 
如何在gridview中实现单击选择的行改变颜色?谢谢大哥大姐们在线狂等[解决办法]protected void dg_Karso_It

如何在gridview中实现单击选择的行改变颜色?
谢谢大哥大姐们   在线狂等

[解决办法]
protected void dg_Karso_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
{
//鼠标移动时变换背景色
ListItemType itemType = e.Item.ItemType;
if(itemType==ListItemType.AlternatingItem || itemType==ListItemType.Item)
{
LinkButton TempLinkbtn =(LinkButton)e.Item.Cells[0].Controls[0];
e.Item.Attributes[ "onclick "] = Page.GetPostBackClientHyperlink(TempLinkbtn, " ");
e.Item.Attributes.Add( "onmouseover ", "currentcolor = this.style.backgroundColor;this.style.backgroundColor= ' " + IRFilter_variable.strColor_dgItemDataBound + " ' ");
//添加自定义属性,当鼠标移走时还原该行的背景色
e.Item.Attributes.Add( "onmouseout ", "this.style.backgroundColor=currentcolor ");
}
}
要有选择项 并为第一列

热点排行
Bad Request.