Argument Out of Range

  • Thread starter Thread starter Dave Bailey
  • Start date Start date
D

Dave Bailey

When I execute the following code:

private void mrGrid_ItemCommand(object source,
System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
if (e.CommandName == "PR")
{
string targetPage
= "prDetailsForm.aspx?PR=" + e.Item.Cells[5].Text;
Response.Redirect(
targetPage, true );
}
}

I get the following error:

Specified argument was out of the range of valid values.
Parameter name: index

I double checked and the information is definitely in Cell
5.

Is there something I am missing?

Thanks,

Dave
 
--------------------
Content-Class: urn:content-classes:message
From: "Dave Bailey" <[email protected]>

When I execute the following code:

private void mrGrid_ItemCommand(object source,
System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
if (e.CommandName == "PR")
{
string targetPage
= "prDetailsForm.aspx?PR=" + e.Item.Cells[5].Text;
Response.Redirect(
targetPage, true );
}
}

I get the following error:

Specified argument was out of the range of valid values.
Parameter name: index

I double checked and the information is definitely in Cell
5.

Is there something I am missing?

Thanks,

Dave

Hi Dave,

In C#, indices are 0-based, which means that the first element in an array
has index 0, and cell 5 has index 4. Thanks,

- Zhanyong Wan

Visual Studio and .NET Setup

This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included samples (if any) is subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm
 
Back
Top