后台设置:
Public Sub dgList_ItemDataBound(ByVal sender As System.Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs)
If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem Then
'--- 增加鼠标效果 OnMouseOver / OnMouseOut
e.Item.Attributes.Add("onmouseover", "this.style.backgroundColor='Silver'")
e.Item.Attributes.Add("onmouseout", "this.style.backgroundColor='#eeeeff'") '--- 改变特定 Cell (Column) 的鼠标式样(Or you may do it for a whole Row of DataGrid :)
e.Item.Cells(1).Style("cursor") = "hand"
end if
end sub
Public Sub dgList_ItemDataBound(ByVal sender As System.Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs)
If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem Then
'--- 增加鼠标效果 OnMouseOver / OnMouseOut
e.Item.Attributes.Add("onmouseover", "this.style.backgroundColor='Silver'")
e.Item.Attributes.Add("onmouseout", "this.style.backgroundColor='#eeeeff'") '--- 改变特定 Cell (Column) 的鼠标式样(Or you may do it for a whole Row of DataGrid :)
e.Item.Cells(1).Style("cursor") = "hand"
end if
end sub
解决方案 »
- url重写
- 这是杂回事 各位大侠们.
- 请教:全自定义用户控件的网站 ,页面跳转(调用控件)是如何实现的?
- 如何插入一条的空的记录
- 加密票据后,读取时候需要解密吗? 我没有解密仍然读出正确数据了,怎么回事情?
- 再次发贴:只有高手才能回答出的简单问题。。。.net1.1 升级成2.0 后,同样一个sha1加密,却得和1.1到不同的字串(分不够再加)
- 大家提提意见!
- 怎么样调论坛的热贴页面
- 日期相减如何得到天数!
- 怎样实现一个类似于hotmail邮件的在线rtf编辑器.
- ...在线等...请问:怎么在datagrid超链接字段的url格式里引用 脚本变量(vb或c#变量)....
- 从WebService得到的DataSet作为xml island如何在客户端与select绑定?
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","currentcolor=this.style.backgroundColor;this.style.backgroundColor='#336699'");
e.Item.Attributes.Add("onmouseout","this.style.backgroundColor=currentcolor");
}
}
function document.onclick()
{
try
{
var ObjTable = document.all.DataGrid1;//DataGrid1改成你的id名
if(ObjTable.contains(event.srcElement) == true)
{
var ThisObj = event.srcElement;
while(ThisObj.tagName != "TR") ThisObj = ThisObj.parentNode;
if(ThisObj != ObjTable.rows[0] && ThisObj != ParentObj)
{
ThisObj.style.color = 'FF0000';
if(ParentObj != null)
{
ParentObj.style.color = '000000';
}
ParentObj = ThisObj;
}
}
}
catch(e){}
}
{
e.Item.Attributes.Add("onmouseover","this.style.backgroundColor='#bfd4e6'");
e.Item.Attributes.Add("onmouseout","this.style.backgroundColor='#fafafa'");
}
在itemcreate中写上面的代码。
Public Sub dgList_ItemDataBound(ByVal sender As System.Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs)
If e.item.itemIndex<>-1 Then
'--- 增加鼠标效果 OnMouseOver / OnMouseOut
e.Item.Attributes.Add("onmouseover", "this.style.backgroundColor='Silver'")
e.Item.Attributes.Add("onmouseout", "this.style.backgroundColor='#eeeeff'") '--- 改变特定 Cell (Column) 的鼠标式样(Or you may do it for a whole Row of DataGrid :)
e.Item.Cells(1).Style("cursor") = "hand"
end if
end sub
我用你的方法试过了,成功了!
如果我在DataGrid上的一行单击,这个单击所触发的事件是什么!
如何绑定事件,举个例子!
谢谢!