possible. Occasionally, I get an error that I just cannot see how it could
ever happen. I enabled debugging on the live site so that I could get
line-number information. But I'm still at a loss.
I've posted an error below, and the code below that. Somehow,
grdWorkout.Data Keys[grdWorkout.Sele ctedIndex] is causing an
ArgumentOutOfRa ngeException, even though I had tested for SelectedIndex
== -1.
Does anyone have any clues as to how this could happen?
Thanks.
System.Web.Http UnhandledExcept ion: Exception of type>>>>ERROR <<<<<
'System.Web.Htt pUnhandledExcep tion' was thrown. --->
System.Argument OutOfRangeExcep tion: Index was out of range. Must be
non-negative and less than the size of the collection.
Parameter name: index
at System.Collecti ons.ArrayList.g et_Item(Int32 index)
at System.Web.UI.W ebControls.Data KeyArray.get_It em(Int32 index)
at ASP.Workouts.bt nSubstitute_Cli ck(Object sender, ImageClickEvent Args e)
in d:\Inetpub\medi corpmap\Control s\Workouts.ascx :line 155
at System.Web.UI.W ebControls.Imag eButton.OnClick (ImageClickEven tArgs e)
at System.Web.UI.W ebControls.Imag eButton.RaisePo stBackEvent(Str ing
eventArgument)
at
System.Web.UI.W ebControls.Imag eButton.System. Web.UI.IPostBac kEventHandler.R aisePostBackEve nt(String
eventArgument)
at System.Web.UI.P age.RaisePostBa ckEvent(IPostBa ckEventHandler
sourceControl, String eventArgument)
at System.Web.UI.P age.RaisePostBa ckEvent(NameVal ueCollection postData)
at System.Web.UI.P age.ProcessRequ estMain(Boolean
includeStagesBe foreAsyncPoint, Boolean includeStagesAf terAsyncPoint)
--- End of inner exception stack trace ---
at System.Web.UI.P age.HandleError (Exception e)
at System.Web.UI.P age.ProcessRequ estMain(Boolean
includeStagesBe foreAsyncPoint, Boolean includeStagesAf terAsyncPoint)
at System.Web.UI.P age.ProcessRequ est(Boolean
includeStagesBe foreAsyncPoint, Boolean includeStagesAf terAsyncPoint)
at System.Web.UI.P age.ProcessRequ est()
at System.Web.UI.P age.ProcessRequ estWithNoAssert (HttpContext context)
at System.Web.UI.P age.ProcessRequ est(HttpContext context)
at ASP.trainer_wor kouts_aspx.Proc essRequest(Http Context context) in
c:\WINDOWS\Micr osoft.NET\Frame work\v2.0.50727 \Temporary ASP.NET
Files\root\f2d4 905b\94fa3b3c\A pp_Web_amhr_qtk .2.cs:line 0
at
System.Web.Http Application.Cal lHandlerExecuti onStep.System.W eb.HttpApplicat ion.IExecutionS tep.Execute()
at System.Web.Http Application.Exe cuteStep(IExecu tionStep step, Boolean&
completedSynchr onously)
if (ddlWorkouts.It ems.Count == 0)>>>>CODE <<<<<
{
ErrorMessage1.S etError("You must first create one or more workouts before
you can exchange workout items.");
}
else if (grdWorkout.Sel ectedIndex == -1)
{
ErrorMessage1.S etError("You must first select an activity in the workout
before you can exchange it.");
}
else
{
EncryptedQueryS tring queries = new EncryptedQueryS tring();
queries["UserID"] = UserID.ToString ();
object obj = TrainerID;
if (obj != null)
queries["TrainerID"] = obj.ToString();
queries["WorkoutID"] = ddlWorkouts.Sel ectedValue;
queries["WorkoutDetailI D"] =
grdWorkout.Data Keys[grdWorkout.Sele ctedIndex].Value.ToString (); // <=====
LINE 155
Response.Redire ct(String.Forma t("{0}?data={1} ", SubstituteItemU rl,
queries), true);
}
--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com