GridView中使用方向键标记选中行
来源:互联网 发布:测试网络丢包命令 编辑:程序博客网 时间:2024/05/17 07:30
在aspx中定义javascript事件,判断按键是否为上下键;
然后在gridview的rowDataBound中, 添加处理按键的事件处理函数和使用鼠标点击某行时的选中事件.
- <script type="text/javascript">
- var currentRowId = 0;
- function SelectRow()
- {
- if (event.keyCode == 40)
- MarkRow(currentRowId+1);
- else if (event.keyCode == 38)
- MarkRow(currentRowId-1);
- }
- function MarkRow(rowId)
- {
- if (document.getElementById(rowId) == null)
- return;
- if (document.getElementById(currentRowId) != null )
- document.getElementById(currentRowId).style.backgroundColor = '#ffffff';
- currentRowId = rowId;
- document.getElementById(rowId).style.backgroundColor = '#ff0000';
- }
- </script>
然后在gridview的rowDataBound中, 添加处理按键的事件处理函数和使用鼠标点击某行时的选中事件.
- protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
- {
- if (e.Row.RowType == DataControlRowType.DataRow)
- {
- e.Row.Attributes.Add("id", _i.ToString());
- e.Row.Attributes.Add("onKeyDown", "SelectRow();");
- e.Row.Attributes.Add("onClick", "MarkRow(" + _i.ToString() + ");");
- _i++;
- }
- }
- GridView中使用方向键标记选中行
- sqlplus中方向键的使用
- GridView 选中行变色
- GridView选中行变色
- GridView导出选中行
- GridView选中行
- GridView选中行变色
- GridView中如何获取所选中行的值?
- GridView中添加CheckBox并返回选中行
- GridView中得到选中的某行的ID值
- 运用Button删除GridView中CheckBox选中行
- gridview中如何定位 选中行的关键值
- 使用javascript实现GridView无刷新选中行(变色)
- 使用javascript实现GridView无刷新选中行(变色)
- DEV GridView 单击行选中/取消选中
- winform中GridView控件在选中一行后改变选中行的背景颜色
- 使用方向键控制table中文本框焦点
- Linux下sqlplus中方向键的使用
- spin_lock宏和spin_unlock宏
- struts2 中json使用体验
- 使用javascript实现GridView无刷新选中行(变色)
- 关于EVC[转]
- JAVA交流QQ群43829453
- GridView中使用方向键标记选中行
- Restlet 指南[Matrix社区试读版]
- SSIS性能调优备忘
- INVEST in Good Stories, and SMART Tasks
- 妹妹的短信
- 什么是Windows API
- Understanding the Login Failed Error in Crystal Reports
- 楼盘广告
- 代码规范