Click to See Complete Forum and Search --> : index out of bound using datalist web control


Madagiri
November 6th, 2004, 06:49 PM
Pls give me a solution for my problem. the problem is

i am trying to update record from the datalist control under Edit command using update command. The code is as follows:

Private Sub dbAddressBook_UpdateCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles dbAddressBook.UpdateCommand

Dim intEmployeeID As Integer
Dim strName, strExtension As String

intEmployeeID = dbAddressBook.DataKeys(e.Item.ItemIndex)
when trying execute this code i am facing the following error:

"Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index

Source Error:


Line 71:
Line 72:
Line 73: intEmployeeID = Me.dlAddressbook.DataKeys(e.Item.ItemIndex)
Line 74:
Line 75: