Existing Connection Example --- DataGrid Connection Examples -- Paging Example -- New Methods/Properties -- Error Properties

"Sort By" example using sort_clsDataGrid.asp

Example #1 with the DataGrid creating the db connection (no styles applied -- just defined by [table] elements in style sheet -- view source to see the style sheet):

Code Used for following DataGrid:
---------------------------------
Set objDataGrid1 = New clsDataGrid
Call objDataGrid1.CreateConnection(strConn1)
objDataGrid1.Command = strQuery1
objDataGrid1.Bind()
Set objDataGrid1 = Nothing

testIDtestCharactertestFromWhattestDate
1John GaltAtlas Shrugged08/10/2002
2Hank ReardonAtlas Shrugged08/10/2002
3Eddie WillersAtlas Shrugged08/10/2002
4Dagny TaggartAtlas Shrugged08/10/2002
5Ragnar DanneskjoldAtlas Shrugged08/10/2002
6Francisco D'AnconiaAtlas Shrugged08/10/2002
7Midas MulliganAtlas Shrugged08/10/2002
8Jerry SeinfeldSeinfeld08/10/2002
9George CostanzaSeinfeld08/10/2002
10Cosmo KramerSeinfeld08/10/2002
12Eric CartmanSouth Park08/10/2002
13Kyle BroflovskiSouth Park08/10/2002
14Stan MarshSouth Park08/10/2002
15Kenny McCormickSouth Park08/10/2002
16Scott TenormanSouth Park08/10/2002
17Elaine BenesSeinfeld08/10/2002
18Kenny BanyaSeinfeld08/10/2002
19Uncle LeoSeinfeld08/10/2002
20Soup NaziSeinfeld08/10/2002
21Priest MaxiSouth Park08/10/2002
22J. PetermanSeinfeld08/10/2002
23NewmanSeinfeld08/10/2002


Example #2 with the DataGrid creating the db connection (inline styles, specifying table props [width, padding, spacing, border], grid table alignment (which should be done with CSS) and autogeneratecols is false so we can add custom column headers). I've shortened some of the styles (end with "...") below so they don't wrap to a new line. To see the full style, view the asp source code.

Code Used for following DataGrid:
---------------------------------
Set objDataGrid2 = New clsDataGrid
Call objDataGrid2.CreateConnection(strConn2)
objDataGrid2.Command = strQuery2
Call objDataGrid2.SetTableOptions(600, 2, 2, 0)
objDataGrid2.GridAlign = "center"
objDataGrid2.GridStyle = "color: #000000; border-style: solid; border-width: 1px; border-color: #666666;"
objDataGrid2.HeaderStyle = "font-family: tahoma, sans-serif; font-size: 12px; font-weight: bold;"...
objDataGrid2.ItemStyle = "font-family: tahoma, sans-serif; font-size: 12px; background-color: #FFEFAD;"...
Call objDataGrid2.BoundColumn("testCharacter", "Character Name")
Call objDataGrid2.BoundColumn("testFromWhat", "From What")
Call objDataGrid2.BoundColumn("testDate", "Date Added")
objDataGrid2.Bind()
Set objDataGrid2 = Nothing

Character NameFrom WhatDate Added
John GaltAtlas Shrugged08/10/2002
Hank ReardonAtlas Shrugged08/10/2002
Eddie WillersAtlas Shrugged08/10/2002
Dagny TaggartAtlas Shrugged08/10/2002
Ragnar DanneskjoldAtlas Shrugged08/10/2002
Francisco D'AnconiaAtlas Shrugged08/10/2002
Midas MulliganAtlas Shrugged08/10/2002
Jerry SeinfeldSeinfeld08/10/2002
George CostanzaSeinfeld08/10/2002
Cosmo KramerSeinfeld08/10/2002
Eric CartmanSouth Park08/10/2002
Kyle BroflovskiSouth Park08/10/2002
Stan MarshSouth Park08/10/2002
Kenny McCormickSouth Park08/10/2002
Scott TenormanSouth Park08/10/2002
Elaine BenesSeinfeld08/10/2002
Kenny BanyaSeinfeld08/10/2002
Uncle LeoSeinfeld08/10/2002
Soup NaziSeinfeld08/10/2002
Priest MaxiSouth Park08/10/2002
J. PetermanSeinfeld08/10/2002
NewmanSeinfeld08/10/2002