User Guide

Table Of Contents
646 Chapter 27: Building Dynamic Forms with cfform Tags
To populate a grid from a query:
1.
Create a new ColdFusion page named grid1.cfm with the following contents:
<cfquery name="empdata" datasource="cfdocexamples">
SELECT * FROM Employee
</cfquery>
<cfform name="Form1" action="submit.cfm" >
<cfgrid name="employee_grid" query="empdata"
selectmode="single">
<cfgridcolumn name="Emp_ID">
<cfgridcolumn name="LastName">
<cfgridcolumn name="Dept_ID">
</cfgrid>
<br>
<cfinput name="submitit" type="Submit" value="Submit">
</cfform>
Note: Use the
cfgridcolumn display="No" attribute to hide columns that you want to include in the
grid but not expose to an end user. You typically use this attribute to include columns such as the
table’s primary key column in the results returned by the
cfgrid tag.
2.
Save the file and view it in your browser.
The following figure shows the output of this code: