色尼玛亚洲综合影院,亚洲3atv精品一区二区三区,麻豆freexxxx性91精品,欧美在线91

asp.net 設(shè)置GridView的選中行

<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中, 添加處理按鍵的事件處理函數(shù)和使用鼠標(biāo)點(diǎn)擊某行時(shí)的選中事件.
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++;
}
}
當(dāng)點(diǎn)某行時(shí),直接選中,然后移動(dòng)方向鍵則切換不同的選中行; 如果直接按方向鍵,則從第一行開始標(biāo)識(shí)

AspNet技術(shù)asp.net 設(shè)置GridView的選中行,轉(zhuǎn)載需保留來源!

鄭重聲明:本文版權(quán)歸原作者所有,轉(zhuǎn)載文章僅為傳播更多信息之目的,如作者信息標(biāo)記有誤,請第一時(shí)間聯(lián)系我們修改或刪除,多謝。

主站蜘蛛池模板: 北川| 固原市| 炎陵县| 巩留县| 云阳县| 罗田县| 资阳市| 尼勒克县| 金塔县| 隆昌县| 沙田区| 双城市| 贞丰县| 姜堰市| 沂源县| 洛阳市| 封开县| 鞍山市| 太白县| 桓台县| 泸溪县| 岳阳县| 龙州县| 寻乌县| 舒城县| 崇明县| 广平县| 商城县| 蛟河市| 沙湾县| 绥江县| 大连市| 溆浦县| 穆棱市| 蒙城县| 渭源县| 合水县| 民县| 同德县| 亚东县| 中阳县|