
Creating an Updateable Grid
161
<br>
</cfoutput>
<cfif Form.employee_grid.rowstatus.action[counter] is "D">
<cfquery name="DeleteExistingEmployee"
datasource="CompanyInfo">
DELETE FROM Employee
WHERE
Emp_ID=#Form.employee_grid.original.Emp_ID
[Counter]#
</cfquery>
<cfelseif Form.employee_grid.rowstatus.action[counter] is "U">
<cfquery name="UpdateExistingEmployee"
datasource="CompanyInfo">
UPDATE Employee
SET
LastName=’#Form.employee_grid.LastName[Counter]#’,
Dept_ID=#Form.employee_grid.Dept_ID[Counter]#
WHERE
Emp_ID=#Form.employee_grid.original.Emp_ID
[Counter]#
</cfquery>
<cfelseif Form.employee_grid.rowstatus.action[counter] is "I">
<cfquery name="InsertNewEmployee"
datasource="CompanyInfo">
INSERT into Employee
(LastName, Dept_ID)
VALUES (’#Form.employee_grid.LastName[Counter]#’,
#Form.employee_grid.Dept_ID[Counter]#)
</cfquery>
</cfif>
</cfloop>
</cfif>
</body>
</html>
3
Rename your existing handle_grid.cfm file if you wish to save it, then save this file
as handle_grid.cfm.
4
View
grid2.cfm
in your browser, make changes to the grid, and then submit
them.
Содержание 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 ...