Sample 2: | Continue To Sample 3 Back To Samples |
Click here
>> Run Sample 2 Note: If you haven't configured your Microsoft Access driver, please click here. |
This sample demonstrates support for multiple iASP_Grids on the same asp page. Two Grids are displayed, the first grid is of the Departments Table, having regular gray <SUBMIT> buttons. The second grid is for the Employee Table having image buttons.
Sample Code:
<%
Set DptGrid = Server.CreateObject("Persits.AspGrid")
DptGrid.FileName = "Sample3.asp"
DptGrid.Connect "sun.jdbc.odbc.JdbcOdbcDriver", "jdbc:Odbc:GridTest", "", ""
DptGrid.SQL = "select id, name, phone from Departments"
DptGrid.Cols(1).Hidden = True
DptGrid.UseImageButtons = FalseSet EmpGrid = Server.CreateObject("Persits.AspGrid")
EmpGrid.FileName = "Sample3.asp"
EmpGrid.Connect "sun.jdbc.odbc.JdbcOdbcDriver", "jdbc:Odbc:GridTest", "", ""
EmpGrid.SQL = "select id, DepartmentID, FirstName, LastName, Salary, MaritalStatus from Employee"
EmpGrid.Cols(1).Hidden = True
EmpGrid.NumberOnPage = 2
EmpGrid.ShowLeftSideButtons False
EmpGrid.Cols(2).AttachForeignTable "select id, name from Departments", 1, 2
EmpGrid.Cols(5).FormatNumeric 2, True
EmpGrid.Cols(5).Cell.Align = "RIGHT"
EmpGrid.Cols(6).Array = Array("Single", "Married", "Divorced")
EmpGrid.Cols(6).VArray = Array(1, 2, 3)
%><HTML>
<BODY><%
DptGrid.Display
DptGrid.Disconnect
%>
<P>
<%
EmpGrid.Display
EmpGrid.Disconnect
%></BODY>
</HTML>
Description:
The first five steps for creating a Grid Object have already been discussed. See the main page of samples for details.
DptGrid.UseImageButtons = False
Causes the Departments grid to display
Gray <SUBMIT> buttons.
EmpGrid.NumberOnPage = 2
When displaying multiple grids on
the same asp page, each grid must have this property set to a unique number.
The default value for the property is one (1). In case of a third
grid on the same page, it must have this property set to any other number
than 1 or 2 to avoid duplication.
EmpGrid.ShowLeftSideButtons
False
This method enables a grid to show
the buttons (add,delete,edit, etc) on the left side. The paramter
is optional. By default it is False, if it is set to True
the control buttons will be displayed on both sides of the grid.
EmpGrid.Cols(2).AttachForeignTable
"select id, name from Departments", 1, 2
This method displays a drop-down
list box in the second column whenever that grid is in the Edit/Add mode.
The values displayed in the list box are retrieved from a foreign table
specified in the SQL statement which is passed as the first parameter to
the method. The second parameter specifies the 1-based field index in the
SQL statement. The values in this field will actually be saved in the data
base for this specific column. The third parameter also specifies
the 1-based field index in the SQL statement. The values in this field
will actually be displayed in the drop-down list box for this specific
column in Edit/Add mode. In the above sample code Department.id
will serve as the database value and Department.name will serve
as the display value. On selection the displayed value is translated
into the respective database value and saved.
EmpGrid.Cols(6).Array = Array("Single",
"Married", "Divorced")
EmpGrid.Cols(6).VArray = Array(1,
2, 3)
Setting these properties for a column
also cause a drop-down list box to be displayed. The
values for the drop-down list box are set using fixed arrays, otherwise
these two lines have the same effect
as the AttachForeignTable method. The values specified in
the Array property are displayed in the list box whereas the values
specified in the VArray property are actually stored in the database.
EmpGrid.Cols(5).FormatNumeric
2, True
This method formats the numeric
data displayed in a column according to the specified parameters. The first
parameter specifies the number of accepted decimal places for the data
in the column. If the second parameter is set to False commas
are not displayed in the number. By default the value is set to True.
Click here >> Run Sample 2 | |
Back to Top | Continue To Sample 3 Back To Samples |
If you require technical support please send complete details about the problem you are having to support@halcyonsoft.com.
Copyright 1998-2000, Halcyon
Software Inc. All rights reserved.