国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > .NET > 正文

asp.net 設置GridView的選中行

2024-07-10 12:39:03
字體:
來源:轉載
供稿:網友
<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++;
}
}
當點某行時,直接選中,然后移動方向鍵則切換不同的選中行; 如果直接按方向鍵,則從第一行開始標識
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 喀什市| 洛阳市| 锡林郭勒盟| 开江县| 清新县| 雷州市| 白水县| 邯郸县| 阿拉善盟| 吉安县| 闵行区| 通化市| 嫩江县| 瑞安市| 马鞍山市| 保康县| 苏尼特右旗| 贞丰县| 博兴县| 曲周县| 柞水县| 白山市| 惠水县| 长海县| 合江县| 平塘县| 娄底市| 永昌县| 商南县| 万山特区| 德江县| 涪陵区| 陆河县| 磐石市| 南宁市| 镇康县| 英德市| 郯城县| 济阳县| 平果县| 海安县|