C#做的网站,想用上下键控制GridView行焦点的移动,大家帮下忙 C#做的网站,想用上下键控制GridView行焦点的移动,大家帮下忙 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 在GridView里使用上下箭头(小键盘旁边)来选择记录希望对楼主有帮助 在前台的页面加上JS脚本:如<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>在后台添加一下index变量的声明,和在Gridview的RowDataBound绑定事件里写,如:protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e){if (e.Row.RowType == DataControlRowType.DataRow){e.Row.Attributes.Add("id",index.ToString());e.Row.Attributes.Add("onKeyDown", "SelectRow();");e.Row.Attributes.Add("onClick", "MarkRow(" +index.ToString() + ");"); index++;}} index变量点具体,我是新手 网页中,如何把同一行的图片和文字设置成垂直局中? 无聊时写了个垃圾号称商务通的东西,就是即时聊天的,大家帮我测下性能 求一个Google Map API做得具有下图功能的Demo 数据库中增加新记录,不刷新网页,如何获知? 读取文件的相对路径问题 计数器,搞了半天,问题还没解决,请大家帮忙看看,谢谢! TextBox取值问题 DataGrid的按钮列(编辑、修改、取消) 对INPUT控件进行类似TOOLTIP的提示功能代码 微软asp.net快速入门怎么没有codebehind的例子,请问哪有?谢谢 UpdateProgress能反应进度吗 如何在打开网页的时候将网页的快捷方式下载到桌面
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>在后台添加一下index变量的声明,和在Gridview的RowDataBound绑定事件里写,如:
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes.Add("id",index.ToString());
e.Row.Attributes.Add("onKeyDown", "SelectRow();");
e.Row.Attributes.Add("onClick", "MarkRow(" +index.ToString() + ");"); index++;
}
}
index变量点具体,我是新手