用户名:
密 码: 记住
您当前的位置:首页 > 网络编程 > Net教程

asp.net 设置GridView的选中行

时间:2015-01-29  来源:互联网  作者:佚名
<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++;
}
}
当点某行时,直接选中,然后移动方向键则切换不同的选中行; 如果直接按方向键,则从第一行开始标识
来顶一下
返回首页
返回首页
推荐资讯
asp.net安全、实用、简单的大容量存储过程分页第1/2页 asp.net安全、实用、简单的大容量存基本上我下面要讲述的侧重点是如何使用,因为其实分页存储过
asp.net System.Net.Mail 发送邮件 asp.net System.Net.Mail 发送邮件举例: 复制代码 代码如下:163.com的邮箱在早期申请的是支持
相关文章
栏目更新
栏目热门