简体   繁体   English

如何使用箭头键在ASP.NET Gridview中上下移动

[英]How to Move up and down in ASP.NET Gridview Using Arrow Keys

I Have A Grid view control in that grid view controls ItemTemplate i have taken textboxes now i want to do is that on pressing down arrow key the cursor which is in first textbox of first row will go to the first textbox of second row 我在网格视图控件ItemTemplate中有一个网格视图控件,现在我想要的是文本框,按向下箭头键,第一行的第一个文本框中的光标将转到第二行的第一个文本框中

This is the Grid view which i want to do the up down 这是我想做的网格视图

Use this URL, it's with code. 使用此URL,它与代码一起使用。 Navigating through text input fields using arrow keys and return 使用箭头键浏览文本输入字段并返回

    <script type="text/javascript">
        $(document).ready(function(){ 
           // get only input tags with class data-entry
           textboxes = $("input.data-entry");
           // now we check to see which browser is being used 
           if ($.browser.mozilla) { 
               $(textboxes).keypress (checkForAction);
              } 
          else { 
              $(textboxes).keydown (checkForAction); 
          } 
      });  

     function checkForAction (event) {
          if (event.keyCode == 13 || 40) {
             currentBoxNumber = textboxes.index(this); 
               if (textboxes[currentBoxNumber + 1] != null) {
                   nextBox = textboxes[currentBoxNumber + 1]
                   nextBox.focus(); 
                   nextBox.select();
                   event.preventDefault();
                   return false;
               }
           } 
       }
    </script>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM