Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. handling key Press, key Up & key Down Events for a data grid on web form

handling key Press, key Up & key Down Events for a data grid on web form

Scheduled Pinned Locked Moved ASP.NET
csshelpquestion
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • 2 Offline
    2 Offline
    2489128
    wrote on last edited by
    #1

    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.

    T 1 Reply Last reply
    0
    • 2 2489128

      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.

      T Offline
      T Offline
      Tim Kohler
      wrote on last edited by
      #2

      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.

      2 1 Reply Last reply
      0
      • T Tim Kohler

        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.

        2 Offline
        2 Offline
        2489128
        wrote on last edited by
        #3

        but i want this only on client side using javascript without postback.

        T 1 Reply Last reply
        0
        • 2 2489128

          but i want this only on client side using javascript without postback.

          T Offline
          T Offline
          Tim Kohler
          wrote on last edited by
          #4

          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.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups