Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > "Index Was Out of Range" Error Message from the DataGrid

Reply
Thread Tools

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

 
 
Clark Choi
Guest
Posts: n/a
 
      01-10-2004
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_It em
(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.OnBubbleEve nt
(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.

 
Reply With Quote
 
 
 
 
Alvin Bruney
Guest
Posts: n/a
 
      01-10-2004
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" <(E-Mail Removed)> wrote in message
news:06a401c3d786$9d1340a0$(E-Mail Removed)...
> 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_It em
> (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.OnBubbleEve nt
> (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.
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Unspecified error Oracle error occurred, but error message could not be retrieved fro kanman Case Modding 0 04-25-2009 02:00 PM
Array bound to Datagrid - getting values out of the datagrid g.o.atkins@gmail.com ASP .Net 1 09-14-2006 12:00 PM
Error message different than Context.Server.GetLastError.Message tshad ASP .Net 0 01-27-2005 06:38 PM
[python] Figured out how to go from email.Message.Message to string David Stockwell Python 1 06-17-2004 08:52 PM
LinkButtons in a DataGrid blanks out my complete DataGrid (WTF !!) BTHOMASinOHIO ASP .Net Datagrid Control 1 08-21-2003 12:47 PM



Advertisments