后台设置:
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
解决方案 »
- 菜鸟求助.......
- 读取html页面的问题
- 关于动态文本框中加一日历控件
- a页面(查询条件)跳转到b页面, 如何实现b页面返回到a页面!查询条件不变?
- 请问有没有用ASP.NET2.0最新技术(如应用新控件等)构建的示例学习网站啊。
- index 页面Session 丢失
- 从安全角度上讲,.net的验证控件安全吗?
- 用pop接收来的邮件是base64编码,怎么解?????
- 请教关于微网站,进来看看吧。。。谢谢
- 求救,一个奇怪的问题,很着急~~
- ...在线等...请问:怎么在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上的一行单击,这个单击所触发的事件是什么!
如何绑定事件,举个例子!
谢谢!