473,387 Members | 1,590 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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

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.

Nov 18 '05 #1
1 2496
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" <ch*******@hotmail.com> wrote in message
news:06****************************@phx.gbl...
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.

Nov 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Andrew MacIntyre | last post by:
I'm seeing a bizarre situation where IndexErrors are being thrown with "tuple index out of range" error strings. The scenario is something like: l = for a, b in l: ...
1
by: kim | last post by:
Scenario (I'm a newbie): I have a datagrid with countries listed and 5 parameters in each row. I want to add a row to this datagrid via an Event Handler. Very basic stuff. This method then call a...
0
by: Eugene | last post by:
Hello all, I've been trying to figure this out for a few days now, and still have no clue what's going on... I have a few related tables in MS Access (Clients, Cars, Sales), and a datagrid,...
1
by: Dave | last post by:
I'm getting the following error on an EditCommand event. This code is running on production web farm and the thing is it doesn't happen all the time. If I get this error, click the back button,...
0
by: Trapulo | last post by:
I've a datagrid filled with a collection of objects that inherits from basecollection. When I remove an item from this collection and then click onto the datagrid, I've always this error: ...
0
by: dalaeth | last post by:
I have searched Google high and low and haven't found anything that works. Here's my problem, hopefully someone will be able to help! I'm using 1.1 Framework, and ODP.NET 9.5.0.7 on a Windows...
8
by: sam | last post by:
hey everybody, this is my first time posting here. i'm pretty new to python and programming in general (as you'll soon work out for yourselves...) i'm trying to code a version of a selection...
35
by: erikwickstrom | last post by:
Hi all, I'm sorry about the newbie question, but I've been searching all afternoon and can't find the answer! I'm trying to get this bit of code to work without triggering the IndexError. ...
0
by: =?Utf-8?B?Q3ltZXI=?= | last post by:
When the datagrid has multi rows and the vertical scrollbar hasn't appeared, if I click the column near the bound or drag horizontal scrollbar, this exception will be throwed. The trace stack as...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.