如何让鼠标经过datagrid的一行时(表头不算)那一行的颜色变成其它颜色呢?datagrid中没有table,是动态生成的 如何让鼠标经过datagrid的一行时(表头不算)那一行的颜色变成其它颜色呢?datagrid中没有table,是动态生成的 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 private void priceadmingrid_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e){ e.Item.Attributes["onmouseout"] = "javascript:this.style.backgroundColor='#dedfde';"; e.Item.Attributes["onmouseover"] = "javascript:this.style.backgroundColor='#fff7ce';cursor='hand';" ;} 再ItemDataBound事件中给DateItem的项增加属性Attributes就好了private void priceadmingrid_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e){ e.Item.Attributes["onmouseout"] = "javascript:this.style.backgroundColor='#dedfde';"; e.Item.Attributes["onmouseover"] = "javascript:this.style.backgroundColor='#fff7ce';cursor='hand';" ;} private void dg_ItemDataBound(object sender, DataGridItemEventArgs e) { if(e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { //颜色交替 e.Item.Attributes.Add("onmouseover","this.style.backgroundColor='seashell'"); if(e.Item.ItemType == ListItemType.Item) { e.Item.Attributes.Add("onmouseout", "this.style.backgroundColor='#ffffff'"); } if(e.Item.ItemType ==ListItemType.AlternatingItem) { e.Item.Attributes.Add("onmouseout", "this.style.backgroundColor='seashell'"); } } } private void dg_ItemDataBound(object sender, DataGridItemEventArgs e) { if(e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { e.Item.Attributes.Add("onmouseover","this.style.backgroundColor='seashell'"); e.Item.Attributes.Add("onmouseout", "this.style.backgroundColor='#ffffff'"); } } private void changeRowColor(object sender,ystem.Web.UI.WebControls.DataGridItemEventArgs e){ //如果是数据项并且是交替项if(e.Item.ItemType == ListItemType.Item || e.Item.ItemType ==ListItemType.AlternatingItem) { //添加自定义属性,当鼠标移过来时设置该行的背景色为"6699ff",并保存原背景色 e.Item.Attributes.Add("onmouseover","currentcolor=this.style.backgroundColor;this.style.backgroundColor='#6699ff'"); //添加自定义属性,当鼠标移走时还原该行的背景色 e.Item.Attributes.Add("onmouseout","this.style.backgroundColor=currentcolor"); } } 浪子的是对的,我也是这么做---------------欢迊来到麦高网-私活兼职首选平台 www.mgao.net http://goody9807.611.cn/Announce/Announce.asp?BoardID=2&ID=1139 哪位高手做过快钱的接口?中文问题! 如何让弹出的层在屏幕处于居中状态 截取 值 用正则 高手来帮我看下。。汗 搞半天了 紧急求助:关于“网银在线的接受程序”为何接收不到数据?? 请问Asp.Net(vb)编写网页,如何调用模块中声明的函数? 请教关于asp:Button 多行文本框动态添加。98%结贴率,大神都来看看 大家应该都遇到的问题,控件位置问题 新手求救!os! 请问有没有画饼状图的控件? 100分讨论一个问题
{ e.Item.Attributes["onmouseout"] = "javascript:this.style.backgroundColor='#dedfde';";
e.Item.Attributes["onmouseover"] = "javascript:this.style.backgroundColor='#fff7ce';cursor='hand';" ;
}
private void priceadmingrid_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
{ e.Item.Attributes["onmouseout"] = "javascript:this.style.backgroundColor='#dedfde';";
e.Item.Attributes["onmouseover"] = "javascript:this.style.backgroundColor='#fff7ce';cursor='hand';" ;
}
{
if(e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
//颜色交替
e.Item.Attributes.Add("onmouseover","this.style.backgroundColor='seashell'");
if(e.Item.ItemType == ListItemType.Item)
{
e.Item.Attributes.Add("onmouseout", "this.style.backgroundColor='#ffffff'");
} if(e.Item.ItemType ==ListItemType.AlternatingItem)
{
e.Item.Attributes.Add("onmouseout", "this.style.backgroundColor='seashell'");
}
}
}
{
if(e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
e.Item.Attributes.Add("onmouseover","this.style.backgroundColor='seashell'");
e.Item.Attributes.Add("onmouseout", "this.style.backgroundColor='#ffffff'");
}
}
{
//如果是数据项并且是交替项
if(e.Item.ItemType == ListItemType.Item || e.Item.ItemType ==ListItemType.AlternatingItem)
{
//添加自定义属性,当鼠标移过来时设置该行的背景色为"6699ff",并保存原背景色
e.Item.Attributes.Add("onmouseover","currentcolor=this.style.backgroundColor;this.style.backgroundColor='#6699ff'");
//添加自定义属性,当鼠标移走时还原该行的背景色
e.Item.Attributes.Add("onmouseout","this.style.backgroundColor=currentcolor"); }
}
欢迊来到麦高网-私活兼职首选平台 www.mgao.net