Now onto the meat and veg, i.e. the Methods, procedures, for your class. These
add the actual functionality to the class:- Public Sub AddColumn(strColName)
If intColCnt = 0 then
pOutPut = "<table width='100%' border=1
cellpadding=0 cellspacing=0>" & vbcrlf
pOutPut = pOutPut & "<tr>" & vbcrlf
End If
pOutPut = pOutPut & "<td><strong>" & strColName
& "</strong></td>" & vbcrlf
intColCnt = intColCnt + 1
End Sub
If we choose to specify our own column names then we call this method to add
a column name. It just adds a new cell to our grid(table) for each column and
this is where the column count comes in. We only want to start the table and
the row if it's at 0. Every other time we want to just add the cell code. Once
thats done, or not if you use AutoColumns, it's on to the Binding of the grid:-
Public Sub Bind
pConn.Open pConnStr
Set pRec = pConn.Execute(pSqlStr)
If pAutoColumns = True then
'assign column names from returned recordset
pOutPut = "<table width='100%' border=1
cellpadding=0 cellspacing=0>" & vbcrlf
pOutPut = pOutPut & "<tr>" & vbcrlf
Redim pColNames(pRec.Fields.Count)
For x = 0 to pRec.Fields.Count - 1
pOutPut = pOutPut & "<td>"
& pRec.Fields(x).Name & "</td>" & vbcrlf
Next
End If
pOutPut = pOutPut & "</tr>" & vbcrlf
pArray = pRec.GetRows
For x = 0 to UBound(pArray, 2)
pOutPut = pOutPut & "<tr>" & vbcrlf
For y = 0 to UBound(pArray, 1)
pOutPut = pOutPut & "<td>" & pArray(y, x) & "</td>" & vbcrlf
Next
pOutPut = pOutPut & "</tr>" & vbcrlf
Next
pOutPut = pOutPut & "</table>" & vbcrlf
Response.Write pOutPut
End Sub
Creating a Datagrid Class in classic ASP
- Introduction
- 2-Dimensional Arrays
- Creating the class
- Analysis of the Class
- More Analysis of the Class
- Using the Class in an asp page
More Analysis of the Class
You might also like...
About the author
Brian O'Connell
Microsoft Certified Applications Developer with 10 years experience developing web based applications using asp, asp.net for a Local Authority in Dublin. Clings to a firm belief that a web appli...
Interested in writing for us? Find out more.
VB 6 books
-
Dynamic Web Application Development with ASP.Net (Computing)
This is the latest book from Cengage Learning on "Dynamic Web Application Development with ASP.NET...
VB 6 forum discussion
-
CorelDRAW VBA: cdrTraceLineDrawing FAILS, producing single linear path instead of Centerline trace?
by dancemanj (0 replies)
-
client/server application using activex
by beautifulheart (0 replies)
-
System Error &H8007007E. The specifed module could not be found.
by swiftsafe (5 replies)
-
Invitation to take part in an academic research study
by researchlab (0 replies)
-
Invitation to take part in an academic research study
by researchlab (0 replies)
VB 6 podcasts
-
Hanselminutes: Startup Series: Buying an Existing Small Company or Online Application
Published 8 years ago, running time 0h34m
Scott talks to Rob Walling about how he purchases small niche products and companies online and revitalizes them. He recently purchased an existing product that consisted of a 300 gig database and tens of thousands of lines of Classic ASP. How did he know it was valuable? What's next?
Comments