User Guide

Table Of Contents
652 Chapter 27: Building Dynamic Forms with cfform Tags
To update the data source with the cfgridupdate tag:
1.
Create a ColdFusion page with the following contents:
<html>
<head>
<title>Update grid values</title>
</head>
<body>
<h3>Updating grid using cfgridupdate tag.</h3>
<cfgridupdate grid="employee_grid"
datasource="cfdocexamples"
tablename="Employee">
Click <a href="grid2.cfm">here</a> to display updated grid.
</body>
</html>
2.
Save the file as handle_grid.cfm.
3.
View the grid2.cfm page in your browser, make changes to the grid, and then submit them.
Note: To update a grid cell, modify the cell contents, and then press Return.
Reviewing the code
The following table describes the highlighted code and its function:
Updating the database with the cfquery tag
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 lets you handle any errors that arise.
To update the data source with the cfquery tag:
1.
Create a ColdFusion page with the following content:
<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 =
Code Description
<cfgridupdate grid="employee_grid"
Updates the database from the Employee_grid grid.
datasource="cfdocexamples"
Updates the cfdocexamples data source.
tablename="Employee"
Updates the Employee table.