You must Sign In to post a response.
  • Category: ASP.NET

    Index was out of range. Must be non-negative and less than the size of the collection.

    In my Grid i had 6 columns edit and update the records successfully ,if i insert new record i got a error

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

    i checked the item index value=-1

    so how can i fix this?

    my code-beind is below

    Protected Sub rgEducation_InsertCommand(ByVal source As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles rgEducation.InsertCommand

    Dim item As Telerik.Web.UI.GridDataItem = DirectCast(e.Item, Telerik.Web.UI.GridDataItem)

    EmpID = item.OwnerTableView.DataKeyValues(item.ItemIndex)("emp_edu_id").ToString()
    .
    .
    .
    .
    End Sub


    Thks
    psk
  • #462457
    Hi,

    Check if you have got a datasource assigned to the Grid, you might also want to check your gridview's row count.

    Best Regards,
    Vasanth Kani

    Personal Blog: http://jmjvasanthkani.blogspot.com/
    Religious Blog: http://rcchurchindia.blogspot.com/

  • #462461
    hi,
    i think your data table is getting cleared before you insert or bind your grid


  • This thread is locked for new responses. Please post your comments and questions as a separate thread.
    If required, refer to the URL of this page in your new post.