"Index Was Out of Range" Error Message from the DataGrid

Discussion in 'ASP .Net' started by Clark Choi, Jan 10, 2004.

  1. Clark Choi

    Clark Choi Guest

    I ran the sample application called Petstore from msdn.
    Everything went fine until I tested Update button on the
    web form to update the database through Datagrid.
    I have been searching the web to track down this error,
    but none of them really explain this problem/solution
    very well.
    I tried hard to debug this, but debuggin itself was
    impossible.

    The error message is as follows:

    Server Error in '/Pets' Application.
    ----------------------------------------------------------
    ----------------------

    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:

    An unhandled exception was generated during the execution
    of the current web request. Information regarding the
    origin and location of the exception can be identified
    using the exception stack trace below.

    Stack Trace:


    [ArgumentOutOfRangeException: Index was out of range.
    Must be non-negative and less than the size of the
    collection.
    Parameter name: index]
    System.Collections.ArrayList.get_Item(Int32 index) +91
    System.Web.UI.WebControls.DataKeyCollection.get_Item
    (Int32 index)
    Pets.PetForm.datagrid_UpdateCommand(Object source,
    DataGridCommandEventArgs e)
    System.Web.UI.WebControls.DataGrid.OnUpdateCommand
    (DataGridCommandEventArgs e)
    System.Web.UI.WebControls.DataGrid.OnBubbleEvent
    (Object source, EventArgs e)
    System.Web.UI.Control.RaiseBubbleEvent(Object source,
    EventArgs args)
    System.Web.UI.WebControls.DataGridItem.OnBubbleEvent
    (Object source, EventArgs e)
    System.Web.UI.Control.RaiseBubbleEvent(Object source,
    EventArgs args)
    System.Web.UI.WebControls.LinkButton.OnCommand
    (CommandEventArgs e)

    System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBa
    ckEventHandler.RaisePostBackEvent(String eventArgument)
    System.Web.UI.Page.RaisePostBackEvent
    (IPostBackEventHandler sourceControl, String
    eventArgument)
    System.Web.UI.Page.RaisePostBackEvent
    (NameValueCollection postData)
    System.Web.UI.Page.ProcessRequestMain()

    ----------------------------------------------------------
    ------

    There is an article Microsoft Knowledge Base Article -
    813832, but this one mentions when ItemCommand event.
    In this Pet application, Datagrid_UpdateCommand is not
    even accessed due to this error.

    Please somebody provide explanation and workaround for
    this.
    I'd appreciate sooo much.
    Thank you.
     
    Clark Choi, Jan 10, 2004
    #1
    1. Advertising

  2. Clark Choi

    Alvin Bruney Guest

    I have a full discussion of this *bug along with a *fix at this address
    http://tinyurl.com/yvqyd

    --
    Regards,
    Alvin Bruney
    Got tidbits? Get it here...
    http://tinyurl.com/3he3b
    "Clark Choi" <> wrote in message
    news:06a401c3d786$9d1340a0$...
    > I ran the sample application called Petstore from msdn.
    > Everything went fine until I tested Update button on the
    > web form to update the database through Datagrid.
    > I have been searching the web to track down this error,
    > but none of them really explain this problem/solution
    > very well.
    > I tried hard to debug this, but debuggin itself was
    > impossible.
    >
    > The error message is as follows:
    >
    > Server Error in '/Pets' Application.
    > ----------------------------------------------------------
    > ----------------------
    >
    > 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:
    >
    > An unhandled exception was generated during the execution
    > of the current web request. Information regarding the
    > origin and location of the exception can be identified
    > using the exception stack trace below.
    >
    > Stack Trace:
    >
    >
    > [ArgumentOutOfRangeException: Index was out of range.
    > Must be non-negative and less than the size of the
    > collection.
    > Parameter name: index]
    > System.Collections.ArrayList.get_Item(Int32 index) +91
    > System.Web.UI.WebControls.DataKeyCollection.get_Item
    > (Int32 index)
    > Pets.PetForm.datagrid_UpdateCommand(Object source,
    > DataGridCommandEventArgs e)
    > System.Web.UI.WebControls.DataGrid.OnUpdateCommand
    > (DataGridCommandEventArgs e)
    > System.Web.UI.WebControls.DataGrid.OnBubbleEvent
    > (Object source, EventArgs e)
    > System.Web.UI.Control.RaiseBubbleEvent(Object source,
    > EventArgs args)
    > System.Web.UI.WebControls.DataGridItem.OnBubbleEvent
    > (Object source, EventArgs e)
    > System.Web.UI.Control.RaiseBubbleEvent(Object source,
    > EventArgs args)
    > System.Web.UI.WebControls.LinkButton.OnCommand
    > (CommandEventArgs e)
    >
    > System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBa
    > ckEventHandler.RaisePostBackEvent(String eventArgument)
    > System.Web.UI.Page.RaisePostBackEvent
    > (IPostBackEventHandler sourceControl, String
    > eventArgument)
    > System.Web.UI.Page.RaisePostBackEvent
    > (NameValueCollection postData)
    > System.Web.UI.Page.ProcessRequestMain()
    >
    > ----------------------------------------------------------
    > ------
    >
    > There is an article Microsoft Knowledge Base Article -
    > 813832, but this one mentions when ItemCommand event.
    > In this Pet application, Datagrid_UpdateCommand is not
    > even accessed due to this error.
    >
    > Please somebody provide explanation and workaround for
    > this.
    > I'd appreciate sooo much.
    > Thank you.
    >
     
    Alvin Bruney, Jan 10, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. yyt

    Index was out of range?

    yyt, Dec 18, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    488
    Hans Kesting
    Dec 19, 2003
  2. =?Utf-8?B?UnVkeQ==?=

    Index was out of range ERROR <NEWBIE ERROR>

    =?Utf-8?B?UnVkeQ==?=, Jul 6, 2005, in forum: ASP .Net
    Replies:
    4
    Views:
    517
    =?Utf-8?B?UnVkeQ==?=
    Jul 6, 2005
  3. =?Utf-8?B?RGF2ZQ==?=

    Intermittent "Index was out of range." error

    =?Utf-8?B?RGF2ZQ==?=, Jul 20, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    770
    =?Utf-8?B?RGF2ZQ==?=
    Jul 21, 2005
  4. Pat
    Replies:
    0
    Views:
    464
  5. Pat
    Replies:
    0
    Views:
    10,775
Loading...

Share This Page