|
Article PS01060658
HOWTO: Preserving external parameters |
Problem Description
When a parameter is passed to AspGrid from another page or frame,
the parameter value is not preserved once a user reloads the page
by clicking on an Edit, Add New, Sort or any other AspGrid button.
For example, your grid may be based on a SELECT statement with a WHERE clause
using an external parameter id, as follows:
Grid.SQL = "select id, name, phone from employees where dept_id = " & Request("id")
Clicking on an edit button once the grid is displayed will cause a run-time error because
Request("id") now evaluates to an empty string.
Solution
To preserve your parameter you must include a corresponding
hidden variable in every form AspGrid internally
generates. To do so, use the top-level property ExtraFormItems , for example:
Grid.ExtraFormItems = "<INPUT TYPE=HIDDEN NAME=id VALUE=" & Request("id") & ">"
It is recommended that you use the generic Request collection instead of
Request.Form or Request.QueryString.
Created: 2/8/2002 5:00:53 AM
Last Modified: 2/9/2002 4:18:33 PM
Copyright © Persits Software, Inc. 1998 - 2023
For technical support, write to support@persits.com.
|
|