当前位置: 代码迷 >> ASP.NET >> 怎么在gridview中实现单击选择的行改变颜色
  详细解决方案

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

热度:608   发布时间:2013-02-25 00:00:00.0
如何在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 ");
}
}
要有选择项 并为第一列
  相关解决方案