Argument Out of Range

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
 
Z

Zhanyong Wan [MSFT]

--------------------
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top