Creating a Datagrid Class in classic ASP

Introduction

Well we've all heard of the wonderful Datagrid in ASP.Net and it's pretty handy to say the least. Then again some of you like me may still be stuck with poor old ASP for the moment. But it's not all bad. With vbscript classes in ASP you can acomplish many things. So I got the urge to try and create my own version of the datagrid.

To create a DataGrid class my first problem was efficiency. When learning how to get records from a database and display them in a table on your asp page you'll quite often do it like this:-

<table>
<%
Do Until objRec.EOF
%>
   <tr>
        <td><%=objRec("name") %></td>
        <td><%=objRec("address") %></td>
        <td><%=objRec("email") %></td>
   </tr>
<%
   objRec.movenext
loop
%>
</table>


This is quite an innefficient way of doing things. A more efficient way of doing things is to use the RecordCount property of the Recordset, for x = 0 to objRec.RecordCount.

You might also like...

Comments

About the author

Brian O'Connell Ireland

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.

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“The most exciting phrase to hear in science, the one that heralds new discoveries, is not 'Eureka!' but 'That's funny...'” - Isaac Asimov