
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
.
4
View
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.
Содержание COLDFUSION 5-DEVELOPING
Страница 1: ...Macromedia Incorporated Developing ColdFusion Applications MacroMedia ColdFusion 5 ...
Страница 58: ...38 Chapter 3 Querying a Database ...
Страница 134: ...114 Chapter 7 Updating Your Database ...
Страница 210: ...190 Chapter 10 Reusing Code ...
Страница 232: ...212 Chapter 11 Preventing and Handling Errors ...
Страница 238: ...218 Chapter 12 Using the Application Framework ...
Страница 262: ...242 Chapter 12 Using the Application Framework ...
Страница 278: ...258 Chapter 13 Extending ColdFusion Pages with CFML Scripting ...
Страница 320: ...300 Chapter 15 Indexing and Searching Data ...
Страница 336: ...316 Chapter 16 Sending and Receiving E mail ...
Страница 374: ...354 Chapter 18 Interacting with Remote Servers ...