2012-04-03 84 views
-1

如何使用像Excel工作表這樣的GridView來輸入記錄?與Excel工作表類似,使用向上/向下箭頭鍵在行中向上/向下移動。GridView在ASP.NET C中插入一行記錄#

我需要插入25行以上的單行記錄(比如說學生的標記),這些記錄由用戶根據他們的註冊號碼輸入。我使用<ItemTemplate>TextBox es,但沒有發現如此靈活地輸入學生的分數。

請幫助我,如果有任何其他方式來做這樣的任務。

回答

0

使用向上/向下箭頭鍵在行中執行向上/向下移動使用此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>