| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 947 人关注过本帖
标题:[求助]鼠标悬停GridView的行时相应的行变色
只看楼主 加入收藏
g82941016
Rank: 1
等 级:新手上路
帖 子:140
专家分:0
注 册:2006-2-23
收藏
 问题点数:0 回复次数:4 
[求助]鼠标悬停GridView的行时相应的行变色

鼠标悬停GridView的行时相应的行变色,这一脚本这哪个事件中写

搜索更多相关主题的帖子: 鼠标 GridView 悬停 变色 行时 
2006-05-24 17:37
lanjinbo
Rank: 1
等 级:新手上路
威 望:1
帖 子:109
专家分:0
注 册:2006-4-14
收藏
得分:0 

这不用在脚本中写呀,可以在DATAGRID中的ItemDataBound属性中写入:
private void DataGrid1_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
{
if(e.Item.ItemType==ListItemType.Item||e.Item.ItemType==ListItemType.AlternatingItem)
{
e.Item.Attributes.Add("onmouseover","c=this.style.backgroundColor;this.style.backgroundColor='yellow'");
e.Item.Attributes.Add("onmouseout","this.style.backgroundColor=c");


}


天蓝蓝,水蓝蓝,扬帆远航,有鱼儿作伴 风嘻嘻,云嘻嘻,共渡幸福彼岸
2006-05-25 00:27
guobinxian
Rank: 1
等 级:新手上路
威 望:2
帖 子:195
专家分:0
注 册:2006-3-28
收藏
得分:0 
恩,顶

?蔾錵輐落溶溶钥,柳絮筂鎕淡淡風?。
2006-05-25 08:55
g82941016
Rank: 1
等 级:新手上路
帖 子:140
专家分:0
注 册:2006-2-23
收藏
得分:0 
但VS2005中GridView并没有ItemDataBound属性
2006-05-25 09:18
qplclxb
Rank: 1
等 级:新手上路
帖 子:10
专家分:0
注 册:2007-7-22
收藏
得分:0 

用RowDataBound事件,如下,(顺便还实现了在客户端确认删除):
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor;this.style.backgroundColor='#6699ff'");
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c");
if (e.Row.Cells[7].Controls.Count > 0)
{
((LinkButton)(e.Row.Cells[7].Controls[0])).Attributes.Add("onclick", "return confirm('你确认删除吗?')");
}
}

}

2007-07-22 22:28
快速回复:[求助]鼠标悬停GridView的行时相应的行变色
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.013730 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved