DgdDHTZ.Items(0).BackColor = Color.AliceBlue
解决方案 »
- GridView的linkbutton
- 我装的IIS默认站点 怎么是启动不了??
- HttpException (0x80004005): 无法验证数据。
- 关于水晶报表的问题。。。。应该不难解决。。。可我还是搞不定啊。。。。help!~
- .NET发不出去邮件问题
- 合并DataTable时,如何消除重复列
- asp.net repeater 如何获取单元格的值?
- 欢迎江雨来坐坐!!关于TREEVIEW中CHECKBOX的问题
- 怎樣安裝Microsoft Message Queue Service.....?????
- 图片显示的问题(很弱智),问题解决马上给分
- 页面链接 FTP链接的命令 serv-U 急?????
- 數據庫轉換問題﹐思歸﹐大力﹐幫幫我﹗﹗﹗﹗﹗﹗﹗﹗﹗
<table>
<tr onmouseover="this.style.backgroundColor='Silver'"onmouseout="this.style.backgroundColor='white'"><td>...</td></tr>
</table>
这是从客户端看到的脚本那么我们可以通过datagrd在绑定数据的ItemDataBound事件
时候将这段脚本加入进去。具体代码如下:
if(e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem){
e.Item.Attributes.Add("onmouseover","this.style.backgroundColor='Silver'");
e.Item.Attributes.Add("onmouseout","this.style.backgroundColor='white'");
}
这样就可以让鼠标移动过行的时候将颜色变成silver移走之后变成white(本色)。
前面的判断可以排除鼠标移动到Head和Foot的时候也有相同的效果,这样可以把脚本
只产生在里面的项上。
或者指定某列变色:
if(e.Item.ItemType == ListItemType.Item || e.Item.ItemType ==
ListItemType.AlternatingItem){
e.Item.Cells[2].Attributes.Add
("onmouseover","this.style.backgroundColor='Silver'");
e.Item.Cells[2].Attributes.Add
("onmouseout","this.style.backgroundColor='white'");
}不但如此你还可以指定鼠标移动到某一列时鼠标的形状:
e.Item.Cells[3].Style("cursor") = "hand"
或者点击某一个单元个显示提示信息:
e.Item.Cells[3].Attributes.Add("onclick", "alert('你点击的ID是: " +
e.Item.Cells[0].Text + "!');")
等等...
通过这个方法我们还可以添加在鼠标移动到行上出现提示的效果
e.Item.Cells[2].Attributes.Add("title","在这里可以添加提示信息");