设置DataGrid的SelectStyle属性就可以实现啦,很简单
解决方案 »
- windows Mobile 上怎么用wmp做在线播放呢?
- asp:Image控件怎么实现绑定数据空白时显示特定图片?
- 前台显示页面把html标记也读出来了,怎么解决呀?
- 想做一些试用版限制,你们有什么建议啊?多谢
- 维护ASP.NET网站的时候把项目里的类里面的提示信息换了,然后把ftp上的BIN文件夹替换了出现下边的异常
- SQL查询是条件字段类型对执行速度影响大吗?
- vs2005 datagrid里找到控件的问题,没分了请包涵......................
- 大家进来看看,通过WebService进行数据处理时遇到的两个问题
- HTML控件Select能不能将列表中所有值传回服务器?
- Request.Url 的域名被请求头里的 Host 替换怎么办
- 请问如何自由的向前向后移动记录?如何转到指定的记录?
- 如何将table1中第x到第y行的数据复制到另一个table2中
1.如 matu(宝贝)所说 设置DataGrid的SelectStyle属性就可以实现
2.
Private Sub dgMessage_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles dgMessage.ItemDataBound
If e.Item.ItemIndex <> -1 Then
'添加自定义属性,当鼠标移过来时设置该行的背景色为"d4e8ff",并保存原背景色
e.Item.Attributes.Add("onmouseover", "currentcolor=this.style.backgroundColor;this.style.backgroundColor='#d4e8ff' ;this.style.cursor='hand'")
'添加自定义属性,当鼠标移走时还原该行的背景色
e.Item.Attributes.Add("onmouseout", "this.style.backgroundColor=currentcolor ;this.style.cursor='hand'")
'当鼠标点击时背景色改变
e.Item.Attributes.Add("onmousedown", "this.style.backgroundColor='f18d34'")
End If
End Sub
{
LinkButton lbDelete=new LinkButton();
lbDelete=e.Item.FindControl("btnDelete") as LinkButton ;
lbDelete.Attributes.Add("onclick","javascript:return confirm('真的要删除记录吗?')");
e.Item.Attributes.Add("onmouseover", "this.style.backgroundColor='#ffced1';this.style.cursor='crosshair'");
//e.Item.Attributes.Add("onclick", "this.style.backgroundColor='#FFC0C0';this.style.cursor='crosshair'");
if (e.Item.ItemType==ListItemType.AlternatingItem )
e.Item.Attributes.Add("onmouseout", "this.style.backgroundColor='#F1EEFF'");
if (e.Item.ItemType == ListItemType.Item)
e.Item.Attributes.Add("onmouseout", "this.style.backgroundColor='#DFDEE7'"); }
呵呵,那个就是cuike519(Knowledge is Power)大哥自己的作品呢。
我在我的程序种实现了,你可以试一下.
^_^
但是你的方法点击过后当鼠标移走后就没有背景色了啊?你发现了吗?
我也试过了,问题同wggwan(明天会更好) 一样,^_^!
难道说只能通过第三方控件才可实现吗?