handling key Press, key Up & key Down Events for a data grid on web form
-
hi! i want to use key event on datagrid for web form as they are available for window-datagrid control. i want ... [1.] when we click a row on client side on the data grid then it will get selected. [2.] now when we press UP ARROW KEY, then next row up to the current row will get selected. [3.] now when we press DOWN ARROW KEY then next row below to the current row will get selected. how will this perform? please help me.
-
hi! i want to use key event on datagrid for web form as they are available for window-datagrid control. i want ... [1.] when we click a row on client side on the data grid then it will get selected. [2.] now when we press UP ARROW KEY, then next row up to the current row will get selected. [3.] now when we press DOWN ARROW KEY then next row below to the current row will get selected. how will this perform? please help me.
You'll need to write a bit of javascript there as most single keystrokes do not, thankfully, cause a postback to the server. Try subscribing to the document.onkeyup event. If you determine that the up or down key was hit, force a postback and handle moving the datagrid selecteditemindex on the server. This will not be super fast as you'll postback a lot, but otherwise, I'm not sure how you can set the selecteditemindex in javascript as I believe it is in the viewstate. Try googling on selecteditemindex and javascript to see if you can make it happen w/o the postback.
-
You'll need to write a bit of javascript there as most single keystrokes do not, thankfully, cause a postback to the server. Try subscribing to the document.onkeyup event. If you determine that the up or down key was hit, force a postback and handle moving the datagrid selecteditemindex on the server. This will not be super fast as you'll postback a lot, but otherwise, I'm not sure how you can set the selecteditemindex in javascript as I believe it is in the viewstate. Try googling on selecteditemindex and javascript to see if you can make it happen w/o the postback.
-
I hear ya. But I'm pretty sure the 'selectedindex' property of the datagrid is in the viewstate, which you are not supposed to mess with on the client manually (1st it's encrypted, 2nd ms says don't do it as they might change the format). Google selectedindex and javascript and datagrid and see what you can come up with.