Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Best way to render massive HTML grid

Status
Not open for further replies.
Jan 26, 2001
550
GB
Hi there, I wonder if anyone could suggest anything to help my situation.

I want to create an extremely large grid (something in the region of 150 squares by 500 squares) which is displayed on a web page. Each square must be clickable and have the ability to enter some information for that particular square. Imagine something along the lines of
Once information has been entered for a square, it is turned into a particular color and has a rollover for that information.
Its fairly easy to achieve this using ASP to draw out a huge table with each cell containing a blank image which links to a page where the information is inputted. The trouble with this is the page takes about a year to load as it loops through each row and cell and makes a db call for each one.

Can anyone suggest an alternative way in which this could be done, to provide a grid that loads much faster?

Many thanks in advance

Nick

Nick (Webmaster)

 
Get all of your data at once rather than making 150x500=75,000 database calls.


 
Hi Nick,

We would need to see an abstracted version of your code to give us a general idea of what you're doing, e.g. how you're retrieving your records and looping etc.

Some things to consider:

1. GetString method of the Recordset object - much much faster than iterating over a recordset yourself.
2. Fast String Concatenation or direct buffer writes - VBScript's string handling is really not good, and gets exponentially worse the more you concatenate. An example of the fast string concatenation:
Code:
class strCat
	dim index, ub, ar()

	Private Sub Class_Initialize()
		redim ar(50)
		index=0
		ub=10
	End Sub

	Private Sub Class_Terminate()
		erase ar
	End Sub

	public default Sub Add(value)
		ar(index)=value
		index=index+1
		if index>ub then
			ub=ub+50
			redim preserve ar(ub)
		end if
	end sub

	public Function dump
		redim preserve ar(index-1)
		dump=join(ar,"")
	end function
end class
I've been using that for a while, and found it here:

3. GetRows if you can't use GetString (returns an array)
4. Client Side Rendering: Generate an XML Data Island/Source and send to the client side - then let the client generate the presentation - depends on the purpose of your application as to whether this would be useful.
5. minimise repetitive content.. pretty obvious, and you've probably got it covered, but don't duplicate code - e.g. style/script etc. per cell.
6. REsponse.Flush - if iterating, flush from time to time to let the browser know things are still happening.
7. You can also try caching the array of records if it is frequently accessed, yet infrequently changed and the SQL to retrieve the content is complex etc.
8. Usually you can make just one call to the database and sort the records in a way that you can iterate over the resulting array (getrows) using simple if then else statements, rather than individual calls.


There are plenty more, but it's kind of like shooting in the dark without knowing what the specific needs are.

Hope that helps,

A smile is worth a thousand kind words. So smile, it's easy! :)
 
HowardMarks wrote:
The trouble with this is the page takes about a year to load as it loops through each row and cell and makes a db call for each one.

Sheco wrote:
Get all of your data at once rather than making 150x500=75,000 database calls.

I agree.

And don't know if this concept would apply at all:

Classic ASP Design Tips - Multiple Records in Each Row


Best regards,
-Paul
- Freelance Web and Database Developer
- Classic ASP Design Tips
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top