C
Clark Choi
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.
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.