473,657 Members | 2,376 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

"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.Argument OutOfRangeExcep tion:
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:
[ArgumentOutOfRa ngeException: Index was out of range.
Must be non-negative and less than the size of the
collection.
Parameter name: index]
System.Collecti ons.ArrayList.g et_Item(Int32 index) +91
System.Web.UI.W ebControls.Data KeyCollection.g et_Item
(Int32 index)
Pets.PetForm.da tagrid_UpdateCo mmand(Object source,
DataGridCommand EventArgs e)
System.Web.UI.W ebControls.Data Grid.OnUpdateCo mmand
(DataGridComman dEventArgs e)
System.Web.UI.W ebControls.Data Grid.OnBubbleEv ent
(Object source, EventArgs e)
System.Web.UI.C ontrol.RaiseBub bleEvent(Object source,
EventArgs args)
System.Web.UI.W ebControls.Data GridItem.OnBubb leEvent
(Object source, EventArgs e)
System.Web.UI.C ontrol.RaiseBub bleEvent(Object source,
EventArgs args)
System.Web.UI.W ebControls.Link Button.OnComman d
(CommandEventAr gs e)

System.Web.UI.W ebControls.Link Button.System.W eb.UI.IPostBa
ckEventHandler. RaisePostBackEv ent(String eventArgument)
System.Web.UI.P age.RaisePostBa ckEvent
(IPostBackEvent Handler sourceControl, String
eventArgument)
System.Web.UI.P age.RaisePostBa ckEvent
(NameValueColle ction postData)
System.Web.UI.P age.ProcessRequ estMain()

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

There is an article Microsoft Knowledge Base Article -
813832, but this one mentions when ItemCommand event.
In this Pet application, Datagrid_Update Command 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 2523
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*******@hotm ail.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.Argument OutOfRangeExcep tion:
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:
[ArgumentOutOfRa ngeException: Index was out of range.
Must be non-negative and less than the size of the
collection.
Parameter name: index]
System.Collecti ons.ArrayList.g et_Item(Int32 index) +91
System.Web.UI.W ebControls.Data KeyCollection.g et_Item
(Int32 index)
Pets.PetForm.da tagrid_UpdateCo mmand(Object source,
DataGridCommand EventArgs e)
System.Web.UI.W ebControls.Data Grid.OnUpdateCo mmand
(DataGridComman dEventArgs e)
System.Web.UI.W ebControls.Data Grid.OnBubbleEv ent
(Object source, EventArgs e)
System.Web.UI.C ontrol.RaiseBub bleEvent(Object source,
EventArgs args)
System.Web.UI.W ebControls.Data GridItem.OnBubb leEvent
(Object source, EventArgs e)
System.Web.UI.C ontrol.RaiseBub bleEvent(Object source,
EventArgs args)
System.Web.UI.W ebControls.Link Button.OnComman d
(CommandEventAr gs e)

System.Web.UI.W ebControls.Link Button.System.W eb.UI.IPostBa
ckEventHandler. RaisePostBackEv ent(String eventArgument)
System.Web.UI.P age.RaisePostBa ckEvent
(IPostBackEvent Handler sourceControl, String
eventArgument)
System.Web.UI.P age.RaisePostBa ckEvent
(NameValueColle ction postData)
System.Web.UI.P age.ProcessRequ estMain()

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

There is an article Microsoft Knowledge Base Article -
813832, but this one mentions when ItemCommand event.
In this Pet application, Datagrid_Update Command 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
4042
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
10765
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 Business method, which calls a Data method which calls an SP in MS SQL. My code compiles well, but the page throws "Index was outside the bounds of the array". I really can't figure why, take a look maybe you pros see can read between the...
0
2752
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, binded to dataview. Here's a catch - whenever I select a client, and then find a car which belongs to this client, and click on empty space in datagrid (that is in gray area below rows) - I get "Index was outside the bounds of the array" error......
1
1925
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, and try again it works. Sometimes it works the first time in. I tried to step through the debugger running locally but I can't duplicate it. Server Error in '/' Application. ---------------------------------------- Index was out of range. Must...
0
1297
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: "Index was outside the bounds of the array datagrid" I've tried this structure: Dim oldList As Business.MyBaseCollection = DirectCast(dgDetails.DataSource,
0
2139
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 2003 Server. I have a cached DataSet that I fill using an OracleDataAdapter. Changes are made to that dataset in memory and as rows are changed, they are updated back to the database using OracleDataAdapter.Update(DataRow). Every few minutes, I...
8
28474
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 sort and the heart of the code is as follows (no_lines is simply the number of items to be sorted, read out of an input file): for j in range(0, no_lines):
35
29216
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. import shutil, os, sys
0
1463
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 follows: at System.Windows.Forms.DataGrid.CreateScrollableRegion(Rectangle scroll) at System.Windows.Forms.DataGrid.set_HorizontalOffset(Int32 value) at System.Windows.Forms.DataGrid.ScrollRight(Int32 columns)\ at...
0
8399
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8312
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8827
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8732
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8606
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6169
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5632
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4318
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1622
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.