<%@ Page language="c#" Codebehind="WebForm10.aspx.cs" AutoEventWireup="false" Inherits="test.WebForm10" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>WebForm10</title>
<META http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
<script language="javascript">
var iSelIndex = 1;
function RowChange()
{
var oTable = document.getElementById("DataGrid1");
var iRowCount = oTable.rows.length;

if(event.keyCode == 38 && iSelIndex>1)
{
oTable.rows[iSelIndex].style.backgroundColor="";
iSelIndex--;
oTable.rows[iSelIndex].style.backgroundColor="red";
}
else if(event.keyCode == 40 && iSelIndex<iRowCount-1)
{
oTable.rows[iSelIndex].style.backgroundColor="";
iSelIndex++;
oTable.rows[iSelIndex].style.backgroundColor="red";
}
}
</script>
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<asp:DataGrid id="DataGrid1" onkeydown="RowChange()" style="Z-INDEX: 101; LEFT: 8px; POSITION: absolute; TOP: 8px" runat="server"></asp:DataGrid>
</form>
</body>
</HTML>