Question: i have write code to delete multiple record in gridview but it only delete one record in gridview. Could someone help me to solve this problem. Here is my code

```
 'This is to Delete multiple records in gridview
Private Sub DeleteMultipleRecords(ByVal idCollection As StringCollection)
    'Create sql Connection and Sql Command
    Dim cnnOLEDB As New OleDbConnection(strConnectionString)
    Dim cmd As New OleDbCommand()
    Dim IDs As String = ""

    'Create string builder to store 
    'delete commands separated by ;

    For Each id As Integer In idCollection
        IDs += id & ","
    Next
    Try
        Dim test As Integer = IDs
        Dim sql As String = "DELETE FROM [1BK] WHERE [sampleID] in (" & test & ")"
        Dim ANS As Integer
        ANS = MsgBox("Are you sure want to delete selected record ?" & vbCrLf & vbCrLf, MsgBoxStyle.YesNo)
        If ANS = vbYes Then
            cmd.CommandType = CommandType.Text
            cmd.CommandText = sql
            cmd.Connection = cnnOLEDB
            cnnOLEDB.Open()
            cmd.ExecuteNonQuery()
        End If
        ANS = 0
    Catch ex As Exception
        Dim errorMsg As String = "Error in Deletion"
        errorMsg += ex.Message
        Throw New Exception(errorMsg)
    Finally
        cnnOLEDB.Close()
    End Try
End Sub

```

Answer: 
*initKeyboardEvent* was originallly *initKeyEvent*, there is a working example at MDN: <https://developer.mozilla.org/en-US/docs/DOM/event.initKeyEvent> and here: <http://www.howtocreate.co.uk/tutorials/javascript/domevents>. 

I'm sure you can find many examples through a web search: "javascript initkeyevent" and "javascript initKeyboardEvent". Likely you will need to test for support to determine which to use.

Note also that *initKeyboardEvent* will be deprecated in [DOM 4 (draft)](http://www.w3.org/TR/dom/) in favour of Event constructor syntax, suggested in [DOM 3](http://www.w3.org/TR/DOM-Level-3-Events/#idl-interface-KeyboardEvent-initializers) and implemented in [DOM 4 (draft)](http://www.w3.org/TR/dom/#interface-event).

A simple feature test might be something like:

```
// Test for Event constructor
if (typeof Event != 'undefined') {
  var x, evt;
  try {
    x = new Event('keyboardEvent');
  } catch(e) {
    x = void 0;
  }
}

// test to see which method to use
if (typeof x != 'undefined') {
  alert('Use Event constructor');

} else if (document.createEvent) {
  evt = document.createEvent('KeyboardEvent');

  if (evt && evt.initKeyboardEvent) {
    alert('Use initKeyboardEvent');

  } else if (evt && evt.initKeyEvent) {
    alert('Use initKeyEvent');
  }
}

```

But for the time being it will likely be best to test for and use DOM 2 *createEvent* with *initKeyEvent* or *initKeyboardEvent* as appropriate. 

Note that Firefox 14 doesn't seem to support *initKeyboardEvent* but does support the *Event* constructor and *initKeyEvent*, IE 9 is the opposite and doesn't support *initKeyEvent* or the *Event* constructor, but does support *initKeyboardEvent*.
See my answer [here](https://stackoverflow.com/a/14561303/1587897)

In short:

Here [Cross-browser initKeyboardEvent](https://gist.github.com/4654819/)

Here [Keyboard Event Level 3 polyfill](https://github.com/termi/DOM-Keyboard-Event-Level-3-polyfill)

Example:

```
var a = new KeyboardEvent("keypress", {"key": 1, "char": "!", shiftKey: true})
alert(a.type + " | " + a.key + " | " + a.char + " | " + a.shiftKey)

```