(一). 示例图片
(二). 代码
[前台]
<script language=“javascript“>
function dbclickevent(d)
{
window.alert(“事件类型: doubleclidk 作用对象: “ + d);
}
function clickevent(d)
{
window.alert(“事件类型: onclick 作用对象: “ + d);
}
function gridviewitemkeydownevent(d)
{
window.alert(“事件类型: gridviewitemkeydownevent 作用对象: “ + d);
}
function keydownevent()
{
if( event.altkey && event.keycode > 48 && event.keycode < 54 )
{
window.alert(“事件类型: formkeydownevent 选中记录数: “ + ( parseint(event.keycode) – 48 ));
}
}
</script>
function dbclickevent(d)
{
window.alert(“事件类型: doubleclidk 作用对象: “ + d);
}
function clickevent(d)
{
window.alert(“事件类型: onclick 作用对象: “ + d);
}
function gridviewitemkeydownevent(d)
{
window.alert(“事件类型: gridviewitemkeydownevent 作用对象: “ + d);
}
function keydownevent()
{
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[“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