Это не полное решение, но оно должно привести вас в правильном направлении.
В событии RowDataBound добавьте событие onkeypress или onkeyup в строку, например:
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
//pass in an argument that will help to determine index of new selection
//for this example, I just chose the row index
e.Row.Attributes["onkeypress"] = String.Format("validateKeyPress({0});", e.Row.RowIndex);
}
Создайте функцию JavaScript для проверки нажатия клавиши и выполните обратную передачу
validateKeyPress = function(rowIndex){
//keycode 37 isn't the up or down key, but you get the idea
//also make sure that the logic here is browser compatible
if (window.event.keyCode == 37){
__doPostBack("<%=GridView1.UniqueID%>", rowIndex);
}
}
В коде позади добавьте переопределение для метода RiasePostBackEvent:
protected override void RaisePostBackEvent(IPostBackEventHandler source, string eventArgument)
{
if (source == GridView1)
{
//add proper validation to avoid out of bounds exception
//this code increments, but you need to add something to increment or decrement
GridView1.SelectedIndex = Int32.Parse(eventArgument) + 1;
}
}