Here is the Sample Code -
<script language="javascript" type="text/javascript">
function keyPressed(TB, e) {
var rowscount = document.getElementById('<%=GridView1.ClientID%>').rows.length;
if (e.keyCode == 40 || e.keyCode == 13) {
if (TB.split("TextBox1_")[1] < (rowscount-2))
document.getElementById(TB.split("TextBox1_")[0] + 'TextBox1_' + eval(TB.split("TextBox1_")[1] + '+1')).focus();
}
if (e.keyCode == 38) {
if (TB.split("TextBox1_")[1] >= 1)
document.getElementById(TB.split("TextBox1_")[0] + 'TextBox1_' + eval(TB.split("TextBox1_")[1] + '-1')).focus();
}
}
</script>
<asp:GridView ID="GridView1" runat="server" AllowPaging="True"
AllowSorting="True" AutoGenerateColumns="False" DataKeyNames="AccessTypeID"
DataSourceID="SqlDataSource1">
<Columns>
<asp:TemplateField HeaderText="type" SortExpression="type">
<ItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("type") %>' onkeyup="keyPressed(this.id,event)"></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:omfConnectionString %>"
SelectCommand="SELECT * FROM [tblAccessType] WHERE ([type] LIKE '%' + @type + '%')">
<SelectParameters>
<asp:Parameter DefaultValue="work phone" Name="type" Type="String" />
</SelectParameters>
</asp:SqlDataSource>