(一). 示例图片
(二). 代码
[前台]
<
scriptlanguage
=
"
javascript
"
>
functionDbClickEvent(d)
{
window.alert( " 事件类型:DoubleClidk作用对象: " + d);
}
functionClickEvent(d)
{
window.alert( " 事件类型:OnClick作用对象: " + d);
}
functionGridViewItemKeyDownEvent(d)
{
window.alert( " 事件类型:GridViewItemKeyDownEvent作用对象: " + d);
}
functionKeyDownEvent()
{
if ( event .altKey && event .keyCode > 48 && event .keyCode < 54 )
{
window.alert( " 事件类型:FormKeyDownEvent选中记录数: " + (parseInt( event .keyCode) - 48 ));
}
}
</ script >
functionDbClickEvent(d)
{
window.alert( " 事件类型:DoubleClidk作用对象: " + d);
}
functionClickEvent(d)
{
window.alert( " 事件类型:OnClick作用对象: " + d);
}
functionGridViewItemKeyDownEvent(d)
{
window.alert( " 事件类型:GridViewItemKeyDownEvent作用对象: " + d);
}
functionKeyDownEvent()
{
if ( event .altKey && event .keyCode > 48 && event .keyCode < 54 )
{
window.alert( " 事件类型:FormKeyDownEvent选中记录数: " + (parseInt( event .keyCode) - 48 ));
}
}
</ script >
[后台]
if
(e.Row.RowType
==
DataControlRowType.DataRow)
{
// 鼠标移动到每项时颜色交替效果
e.Row.Attributes.Add( " OnMouseOut " , " this.style.backgroundColor='White';this.style.color='#003399' " );
e.Row.Attributes.Add( " OnMouseOver " , " this.style.backgroundColor='#6699FF';this.style.color='#8C4510' " );
// 单击/双击事件
e.Row.Attributes.Add("OnDblClick","DbClickEvent('"+e.Row.Cells[1].Text+"')");
e.Row.Attributes.Add( " OnClick " , " ClickEvent(' " + e.Row.Cells[ 1 ].Text + " ') " );
e.Row.Attributes.Add("OnKeyDown","GridViewItemKeyDownEvent('"+e.Row.Cells[1].Text+"')");
// 设置悬浮鼠标指针形状为"小手"
e.Row.Attributes[ " style " ] = " Cursor:hand " ;
}
{
// 鼠标移动到每项时颜色交替效果
e.Row.Attributes.Add( " OnMouseOut " , " this.style.backgroundColor='White';this.style.color='#003399' " );
e.Row.Attributes.Add( " OnMouseOver " , " this.style.backgroundColor='#6699FF';this.style.color='#8C4510' " );
// 单击/双击事件
e.Row.Attributes.Add("OnDblClick","DbClickEvent('"+e.Row.Cells[1].Text+"')");
e.Row.Attributes.Add( " OnClick " , " ClickEvent(' " + e.Row.Cells[ 1 ].Text + " ') " );
e.Row.Attributes.Add("OnKeyDown","GridViewItemKeyDownEvent('"+e.Row.Cells[1].Text+"')");
// 设置悬浮鼠标指针形状为"小手"
e.Row.Attributes[ " style " ] = " Cursor:hand " ;
}
* 关于事件,不仅仅就这些, 还有更多, 用类似方法可以完成更复杂,效果更佳的页面.
(三). 示例代码下载
http://www.cnblogs.com/Files/ChengKing/Gridview(DBclick%20OnmouseOver%20etc).rar