Strange Errors

  • Thread starter Thread starter Jonathan Wood
  • Start date Start date
J

Jonathan Wood

I'm having my site email errors to me until I get things as stable as
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.DataKeys[grdWorkout.SelectedIndex] is causing an
ArgumentOutOfRangeException, even though I had tested for SelectedIndex
== -1.

Does anyone have any clues as to how this could happen?

Thanks.

System.Web.HttpUnhandledException: Exception of type
'System.Web.HttpUnhandledException' was thrown. --->
System.ArgumentOutOfRangeException: Index was out of range. Must be
non-negative and less than the size of the collection.
Parameter name: index
at System.Collections.ArrayList.get_Item(Int32 index)
at System.Web.UI.WebControls.DataKeyArray.get_Item(Int32 index)
at ASP.Workouts.btnSubstitute_Click(Object sender, ImageClickEventArgs e)
in d:\Inetpub\medicorpmap\Controls\Workouts.ascx:line 155
at System.Web.UI.WebControls.ImageButton.OnClick(ImageClickEventArgs e)
at System.Web.UI.WebControls.ImageButton.RaisePostBackEvent(String
eventArgument)
at
System.Web.UI.WebControls.ImageButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String
eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler
sourceControl, String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
at System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
--- End of inner exception stack trace ---
at System.Web.UI.Page.HandleError(Exception e)
at System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest()
at System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context)
at System.Web.UI.Page.ProcessRequest(HttpContext context)
at ASP.trainer_workouts_aspx.ProcessRequest(HttpContext context) in
c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET
Files\root\f2d4905b\94fa3b3c\App_Web_amhr_qtk.2.cs:line 0
at
System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean&
completedSynchronously)

if (ddlWorkouts.Items.Count == 0)
{
ErrorMessage1.SetError("You must first create one or more workouts before
you can exchange workout items.");
}
else if (grdWorkout.SelectedIndex == -1)
{
ErrorMessage1.SetError("You must first select an activity in the workout
before you can exchange it.");
}
else
{
EncryptedQueryString queries = new EncryptedQueryString();
queries["UserID"] = UserID.ToString();
object obj = TrainerID;
if (obj != null)
queries["TrainerID"] = obj.ToString();
queries["WorkoutID"] = ddlWorkouts.SelectedValue;
queries["WorkoutDetailID"] =
grdWorkout.DataKeys[grdWorkout.SelectedIndex].Value.ToString(); // <=====
LINE 155
Response.Redirect(String.Format("{0}?data={1}", SubstituteItemUrl,
queries), true);
}
 
You tested for -1 on selectedindex, you have not tested for the validity of
the datakeys collection which is where the error is coming from. What you
need is this:

if(grdWorkout.DataKeys.Length > 0)
queries["WorkoutDetailID"] =
grdWorkout.DataKeys[grdWorkout.SelectedIndex].Value.ToString();

The datakeys collection holds keys relating to the records in the bound
control. However, the framework does not explicitly guarantee that these
keys will available when you need them. There is only a reasonable
expectation that the keys will be available. You must test the collection
before you use it - test and load pattern.

This isn't a common occurrence, you will likely hit this every once in a
while and typically while the site is under heavy load. I suspect that this
is related to a locked collection in the framework at the moment of access
but that's just a wild guess based on similar occurrences with collections.

--

Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The O.W.C. Black Book, 2nd Edition
Exclusively on www.lulu.com/owc $19.99
-------------------------------------------------------


Jonathan Wood said:
I'm having my site email errors to me until I get things as stable as
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.DataKeys[grdWorkout.SelectedIndex] is causing an
ArgumentOutOfRangeException, even though I had tested for SelectedIndex
== -1.

Does anyone have any clues as to how this could happen?

Thanks.

System.Web.HttpUnhandledException: Exception of type
'System.Web.HttpUnhandledException' was thrown. --->
System.ArgumentOutOfRangeException: Index was out of range. Must be
non-negative and less than the size of the collection.
Parameter name: index
at System.Collections.ArrayList.get_Item(Int32 index)
at System.Web.UI.WebControls.DataKeyArray.get_Item(Int32 index)
at ASP.Workouts.btnSubstitute_Click(Object sender, ImageClickEventArgs
e) in d:\Inetpub\medicorpmap\Controls\Workouts.ascx:line 155
at System.Web.UI.WebControls.ImageButton.OnClick(ImageClickEventArgs e)
at System.Web.UI.WebControls.ImageButton.RaisePostBackEvent(String
eventArgument)
at
System.Web.UI.WebControls.ImageButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String
eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler
sourceControl, String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
at System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
--- End of inner exception stack trace ---
at System.Web.UI.Page.HandleError(Exception e)
at System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest()
at System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context)
at System.Web.UI.Page.ProcessRequest(HttpContext context)
at ASP.trainer_workouts_aspx.ProcessRequest(HttpContext context) in
c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET
Files\root\f2d4905b\94fa3b3c\App_Web_amhr_qtk.2.cs:line 0
at
System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean&
completedSynchronously)

if (ddlWorkouts.Items.Count == 0)
{
ErrorMessage1.SetError("You must first create one or more workouts
before you can exchange workout items.");
}
else if (grdWorkout.SelectedIndex == -1)
{
ErrorMessage1.SetError("You must first select an activity in the workout
before you can exchange it.");
}
else
{
EncryptedQueryString queries = new EncryptedQueryString();
queries["UserID"] = UserID.ToString();
object obj = TrainerID;
if (obj != null)
queries["TrainerID"] = obj.ToString();
queries["WorkoutID"] = ddlWorkouts.SelectedValue;
queries["WorkoutDetailID"] =
grdWorkout.DataKeys[grdWorkout.SelectedIndex].Value.ToString(); // <=====
LINE 155
Response.Redirect(String.Format("{0}?data={1}", SubstituteItemUrl,
queries), true);
}
 
Alvin,

Perhaps that's it. But if so then I don't get how DataKeys could ever be
empty. In my GridView, DataKeyNames is equal to one of the bound fields (the
primary key). Since this normally works, I know it's spelled correctly, etc.

Can you imagine any scenario where this would result in an empty DataKeys
collection?

And if this isn't odd enough, the user at the time is clear that he didn't
get any error. I wish I could explain a couple of things I'm curretnly
seeing.

Thanks.

--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com


Alvin Bruney said:
You tested for -1 on selectedindex, you have not tested for the validity
of the datakeys collection which is where the error is coming from. What
you need is this:

if(grdWorkout.DataKeys.Length > 0)
queries["WorkoutDetailID"] =
grdWorkout.DataKeys[grdWorkout.SelectedIndex].Value.ToString();

The datakeys collection holds keys relating to the records in the bound
control. However, the framework does not explicitly guarantee that these
keys will available when you need them. There is only a reasonable
expectation that the keys will be available. You must test the collection
before you use it - test and load pattern.

This isn't a common occurrence, you will likely hit this every once in a
while and typically while the site is under heavy load. I suspect that
this is related to a locked collection in the framework at the moment of
access but that's just a wild guess based on similar occurrences with
collections.

--

Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The O.W.C. Black Book, 2nd Edition
Exclusively on www.lulu.com/owc $19.99
-------------------------------------------------------


Jonathan Wood said:
I'm having my site email errors to me until I get things as stable as
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.DataKeys[grdWorkout.SelectedIndex] is causing an
ArgumentOutOfRangeException, even though I had tested for SelectedIndex
== -1.

Does anyone have any clues as to how this could happen?

Thanks.
ERROR <<<<<

System.Web.HttpUnhandledException: Exception of type
'System.Web.HttpUnhandledException' was thrown. --->
System.ArgumentOutOfRangeException: Index was out of range. Must be
non-negative and less than the size of the collection.
Parameter name: index
at System.Collections.ArrayList.get_Item(Int32 index)
at System.Web.UI.WebControls.DataKeyArray.get_Item(Int32 index)
at ASP.Workouts.btnSubstitute_Click(Object sender, ImageClickEventArgs
e) in d:\Inetpub\medicorpmap\Controls\Workouts.ascx:line 155
at System.Web.UI.WebControls.ImageButton.OnClick(ImageClickEventArgs e)
at System.Web.UI.WebControls.ImageButton.RaisePostBackEvent(String
eventArgument)
at
System.Web.UI.WebControls.ImageButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String
eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler
sourceControl, String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
at System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
--- End of inner exception stack trace ---
at System.Web.UI.Page.HandleError(Exception e)
at System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest()
at System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context)
at System.Web.UI.Page.ProcessRequest(HttpContext context)
at ASP.trainer_workouts_aspx.ProcessRequest(HttpContext context) in
c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET
Files\root\f2d4905b\94fa3b3c\App_Web_amhr_qtk.2.cs:line 0
at
System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean&
completedSynchronously)
CODE <<<<<

if (ddlWorkouts.Items.Count == 0)
{
ErrorMessage1.SetError("You must first create one or more workouts
before you can exchange workout items.");
}
else if (grdWorkout.SelectedIndex == -1)
{
ErrorMessage1.SetError("You must first select an activity in the
workout before you can exchange it.");
}
else
{
EncryptedQueryString queries = new EncryptedQueryString();
queries["UserID"] = UserID.ToString();
object obj = TrainerID;
if (obj != null)
queries["TrainerID"] = obj.ToString();
queries["WorkoutID"] = ddlWorkouts.SelectedValue;
queries["WorkoutDetailID"] =
grdWorkout.DataKeys[grdWorkout.SelectedIndex].Value.ToString(); // <=====
LINE 155
Response.Redirect(String.Format("{0}?data={1}", SubstituteItemUrl,
queries), true);
}
 
It's most likely not empty, it's just probably locked, in an update state,
at the exact time that a get_item is occurring. Depending on the type of
locking used to secure the resource while it is being updated, collection
readers would get that issue. Your code wouldn't be able to 'fix' it, your
code would simply protect itself from it. That would happen mostly under
heavy load. That's just one theory. The other theory is that this may be a
bug in the framework. If you think it is, you'd have to be able to reproduce
it in order to get a fix.

--

Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The O.W.C. Black Book, 2nd Edition
Exclusively on www.lulu.com/owc $19.99
-------------------------------------------------------


Jonathan Wood said:
Alvin,

Perhaps that's it. But if so then I don't get how DataKeys could ever be
empty. In my GridView, DataKeyNames is equal to one of the bound fields
(the primary key). Since this normally works, I know it's spelled
correctly, etc.

Can you imagine any scenario where this would result in an empty DataKeys
collection?

And if this isn't odd enough, the user at the time is clear that he didn't
get any error. I wish I could explain a couple of things I'm curretnly
seeing.

Thanks.

--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com


Alvin Bruney said:
You tested for -1 on selectedindex, you have not tested for the validity
of the datakeys collection which is where the error is coming from. What
you need is this:

if(grdWorkout.DataKeys.Length > 0)
queries["WorkoutDetailID"] =
grdWorkout.DataKeys[grdWorkout.SelectedIndex].Value.ToString();

The datakeys collection holds keys relating to the records in the bound
control. However, the framework does not explicitly guarantee that these
keys will available when you need them. There is only a reasonable
expectation that the keys will be available. You must test the collection
before you use it - test and load pattern.

This isn't a common occurrence, you will likely hit this every once in a
while and typically while the site is under heavy load. I suspect that
this is related to a locked collection in the framework at the moment of
access but that's just a wild guess based on similar occurrences with
collections.

--

Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The O.W.C. Black Book, 2nd Edition
Exclusively on www.lulu.com/owc $19.99
-------------------------------------------------------


Jonathan Wood said:
I'm having my site email errors to me until I get things as stable as
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.DataKeys[grdWorkout.SelectedIndex] is causing an
ArgumentOutOfRangeException, even though I had tested for SelectedIndex
== -1.

Does anyone have any clues as to how this could happen?

Thanks.

ERROR <<<<<

System.Web.HttpUnhandledException: Exception of type
'System.Web.HttpUnhandledException' was thrown. --->
System.ArgumentOutOfRangeException: Index was out of range. Must be
non-negative and less than the size of the collection.
Parameter name: index
at System.Collections.ArrayList.get_Item(Int32 index)
at System.Web.UI.WebControls.DataKeyArray.get_Item(Int32 index)
at ASP.Workouts.btnSubstitute_Click(Object sender, ImageClickEventArgs
e) in d:\Inetpub\medicorpmap\Controls\Workouts.ascx:line 155
at System.Web.UI.WebControls.ImageButton.OnClick(ImageClickEventArgs
e)
at System.Web.UI.WebControls.ImageButton.RaisePostBackEvent(String
eventArgument)
at
System.Web.UI.WebControls.ImageButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String
eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler
sourceControl, String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
at System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
--- End of inner exception stack trace ---
at System.Web.UI.Page.HandleError(Exception e)
at System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest()
at System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context)
at System.Web.UI.Page.ProcessRequest(HttpContext context)
at ASP.trainer_workouts_aspx.ProcessRequest(HttpContext context) in
c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET
Files\root\f2d4905b\94fa3b3c\App_Web_amhr_qtk.2.cs:line 0
at
System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step,
Boolean& completedSynchronously)

CODE <<<<<

if (ddlWorkouts.Items.Count == 0)
{
ErrorMessage1.SetError("You must first create one or more workouts
before you can exchange workout items.");
}
else if (grdWorkout.SelectedIndex == -1)
{
ErrorMessage1.SetError("You must first select an activity in the
workout before you can exchange it.");
}
else
{
EncryptedQueryString queries = new EncryptedQueryString();
queries["UserID"] = UserID.ToString();
object obj = TrainerID;
if (obj != null)
queries["TrainerID"] = obj.ToString();
queries["WorkoutID"] = ddlWorkouts.SelectedValue;
queries["WorkoutDetailID"] =
grdWorkout.DataKeys[grdWorkout.SelectedIndex].Value.ToString(); //
<===== LINE 155
Response.Redirect(String.Format("{0}?data={1}", SubstituteItemUrl,
queries), true);
}
 
Yeah, the site is only just being beta tested and hasn't been exposed to a
heavy load. Based on my experience, an ASP.NET bug is a distinct
possibility. However, that's pretty much speculation here.

Thanks.

Jonathan

Alvin Bruney said:
It's most likely not empty, it's just probably locked, in an update state,
at the exact time that a get_item is occurring. Depending on the type of
locking used to secure the resource while it is being updated, collection
readers would get that issue. Your code wouldn't be able to 'fix' it, your
code would simply protect itself from it. That would happen mostly under
heavy load. That's just one theory. The other theory is that this may be a
bug in the framework. If you think it is, you'd have to be able to
reproduce it in order to get a fix.

--

Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The O.W.C. Black Book, 2nd Edition
Exclusively on www.lulu.com/owc $19.99
-------------------------------------------------------


Jonathan Wood said:
Alvin,

Perhaps that's it. But if so then I don't get how DataKeys could ever be
empty. In my GridView, DataKeyNames is equal to one of the bound fields
(the primary key). Since this normally works, I know it's spelled
correctly, etc.

Can you imagine any scenario where this would result in an empty DataKeys
collection?

And if this isn't odd enough, the user at the time is clear that he
didn't get any error. I wish I could explain a couple of things I'm
curretnly seeing.

Thanks.

--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com


Alvin Bruney said:
You tested for -1 on selectedindex, you have not tested for the validity
of the datakeys collection which is where the error is coming from. What
you need is this:

if(grdWorkout.DataKeys.Length > 0)
queries["WorkoutDetailID"] =
grdWorkout.DataKeys[grdWorkout.SelectedIndex].Value.ToString();

The datakeys collection holds keys relating to the records in the bound
control. However, the framework does not explicitly guarantee that these
keys will available when you need them. There is only a reasonable
expectation that the keys will be available. You must test the
collection before you use it - test and load pattern.

This isn't a common occurrence, you will likely hit this every once in a
while and typically while the site is under heavy load. I suspect that
this is related to a locked collection in the framework at the moment of
access but that's just a wild guess based on similar occurrences with
collections.

--

Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The O.W.C. Black Book, 2nd Edition
Exclusively on www.lulu.com/owc $19.99
-------------------------------------------------------


I'm having my site email errors to me until I get things as stable as
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.DataKeys[grdWorkout.SelectedIndex] is causing an
ArgumentOutOfRangeException, even though I had tested for SelectedIndex
== -1.

Does anyone have any clues as to how this could happen?

Thanks.

ERROR <<<<<

System.Web.HttpUnhandledException: Exception of type
'System.Web.HttpUnhandledException' was thrown. --->
System.ArgumentOutOfRangeException: Index was out of range. Must be
non-negative and less than the size of the collection.
Parameter name: index
at System.Collections.ArrayList.get_Item(Int32 index)
at System.Web.UI.WebControls.DataKeyArray.get_Item(Int32 index)
at ASP.Workouts.btnSubstitute_Click(Object sender,
ImageClickEventArgs e) in
d:\Inetpub\medicorpmap\Controls\Workouts.ascx:line 155
at System.Web.UI.WebControls.ImageButton.OnClick(ImageClickEventArgs
e)
at System.Web.UI.WebControls.ImageButton.RaisePostBackEvent(String
eventArgument)
at
System.Web.UI.WebControls.ImageButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String
eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler
sourceControl, String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection
postData)
at System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
--- End of inner exception stack trace ---
at System.Web.UI.Page.HandleError(Exception e)
at System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest()
at System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context)
at System.Web.UI.Page.ProcessRequest(HttpContext context)
at ASP.trainer_workouts_aspx.ProcessRequest(HttpContext context) in
c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET
Files\root\f2d4905b\94fa3b3c\App_Web_amhr_qtk.2.cs:line 0
at
System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step,
Boolean& completedSynchronously)

CODE <<<<<

if (ddlWorkouts.Items.Count == 0)
{
ErrorMessage1.SetError("You must first create one or more workouts
before you can exchange workout items.");
}
else if (grdWorkout.SelectedIndex == -1)
{
ErrorMessage1.SetError("You must first select an activity in the
workout before you can exchange it.");
}
else
{
EncryptedQueryString queries = new EncryptedQueryString();
queries["UserID"] = UserID.ToString();
object obj = TrainerID;
if (obj != null)
queries["TrainerID"] = obj.ToString();
queries["WorkoutID"] = ddlWorkouts.SelectedValue;
queries["WorkoutDetailID"] =
grdWorkout.DataKeys[grdWorkout.SelectedIndex].Value.ToString(); //
<===== LINE 155
Response.Redirect(String.Format("{0}?data={1}", SubstituteItemUrl,
queries), true);
}
 
Back
Top