User Guide
160 Chapter 9 Building Dynamic Forms
To update the data source with cfgridupdate
1 Open a new file in ColdFusion Studio.
2 Modify the file so that it appears as follows:
<cfgridupdate grid="Employee_grid"
datasource="CompanyInfo"
tablename="Employee">
3 Save the file as handle_grid.cfm.
4View
grid2.cfm in your browser, make changes to the grid, and then submit
them.
Reviewing the code
The following table describes the code and its function:
Updating the database with cfquery
You can use the cfquery tag to update your database from the cfgrid changes. This
provides you with full control over how the updates are made and allows you to
handle any errors that arise.
To update the data source with cfquery:
1 Open a new file in ColdFusion Studio.
2 Modify the file so that it appears as follows:
<html>
<head>
<title>Catch submitted grid values</title>
</head>
<body>
<h3>Grid values for Form.employee_grid row updates</h3>
<cfif isdefined("Form.employee_grid.rowstatus.action")>
<cfloop index = "Counter" from = "1" to =
#arraylen(Form.employee_grid.rowstatus.action)#>
<cfoutput>
The row action for #Counter# is:
#Form.employee_grid.rowstatus.action[Counter]#
Code Description
<cfgridupdate grid="Employee_grid"
Update the database from the
Employee_grid grid.
datasource="CompanyInfo"
Update the CompanyInfo data source.
tablename="Employee"
Update the Employee table.