Persits Software, Inc. Knowledge Base Articles

Index out of range error

Problem Description

When using data-bound forms with AspGrid, a line such as

<TD><% = Row(3).Value %></TD> :

may generate the following error:

Persits.Grid.1 (0x800A0027)
Index out of range.

Solution

The form methods (GET or POST) used by a button invoking the Add New mode and the actual data-bound form must match. In our sample files list.asp and form.asp the Add New button is implemented by the following code:

<FORM ACTION="form.asp">
<INPUT TYPE="HIDDEN" NAME="AspGridAdd1" VALUE="1">
<INPUT TYPE="SUBMIT" VALUE="Add New">
</FORM>

The form method is GET by default. The data-bound form implemented by form.asp also uses the GET method. If you choose to use the POST method in form.asp by setting the property

Grid.MethodGet = False

you must also specify the POST method for your Add New button, as follows:

<FORM ACTION="form.asp" METHOD="POST">
...
</FORM>