Why is my dynamically added TemplCol so slow?

J

Justin Dutoit

Hey. I'd appreciate if someone could improve the performance of my
TemplateColumn. It runs nicely with one template, and very slow with
another.

If you could please look at my page-
http://eu.webmatrixhosting.net/justindutoit/test/testBufferOff3.aspx?multipl
esearch=milk%2C+bread%2C+juice%2C+cheese%2C%09

Now if I use a different template, it's much faster:

http://eu.webmatrixhosting.net/justindutoit/test/testBufferOff2.aspx?multipl
esearch=milk%2C+bread%2C+juice%2C+cheese%2C%09

I would be thankful if someone could tell me why BufferOff3.aspx is slow,
and BufferOff2.aspx is fast. Here are the two templates, first the slow one:

l.Text = "<A href=\"javascript:void(0)\" onclick=\"parent.left.buyItem('"
+
((DataRowView)container.DataItem)["productnumber"].ToString() +
"', '" + ((DataRowView)container.DataItem)["brand"].ToString() +
"', '" + ((DataRowView)container.DataItem)["productname"].ToString() +
"', '" + ((DataRowView)container.DataItem)["price"].ToString() +
"');\"><img src='add2.jpg' border=0
onmouseover=this.src='add2mouseover.jpg' onmouseout=this.src='add2.jpg'
title='Click to buy one of this item'></A>";

--- and here is the fast one ---


l.Text = "In brackets[" +
((DataRowView)container.DataItem)["productnumber"].ToString() +
"', '" + ((DataRowView)container.DataItem)["brand"].ToString() +
"', '" + ((DataRowView)container.DataItem)["productname"].ToString() +
"', '" + ((DataRowView)container.DataItem)["price"].ToString() +
"]";


It doesn't matter whether I use LoadTemplate or inherit from ITemplate and
use new MyTemplateColumn, my template column is still way too slow.

(I tried two methods of adding a template column in code:
http://www.dotnetbips.com/displayarticle.aspx?id=84
which is LoadTemplate from an ascx file, and
http://www.dotnetbips.com/displayarticle.aspx?id=85
which is to roll your own ITemplate, and use New MyTemplateColumn.)

Here is the code which creates the column:

Dim MyTemplate As ITemplate = New MySlowTemplateColumn("brand")
Dim ColumnBuy As TemplateColumn = New TemplateColumn
ColumnBuy.HeaderText = "&nbsp;Buy&nbsp;"
ColumnBuy.ItemTemplate = MyTemplate
NextGrid.Columns.Add(ColumnBuy)
 
J

Justin Dutoit

I removed the <IMG> tag from my template, and the performance is much
better. I still want to keep that image, but the cause seems to be isolated
....

Tks
Justin
 
J

Justin Dutoit

No, it's not the highlighting on moouseover that is slow, it seems that the
template loads much slower, so the rendering of the grid is slow....

Justin

Prasad said:
Hi

Try preloading the images in JavaScript. so that it will be faster.

HTH
Prasad
Justin Dutoit said:
I removed the <IMG> tag from my template, and the performance is much
better. I still want to keep that image, but the cause seems to be isolated
...

Tks
Justin
http://eu.webmatrixhosting.net/just...justindutoit/test/testBufferOff2.aspx?multipl
esearch=milk%2C+bread%2C+juice%2C+cheese%2C%09

I would be thankful if someone could tell me why BufferOff3.aspx is slow,
and BufferOff2.aspx is fast. Here are the two templates, first the
slow
one:
l.Text = "<A href=\"javascript:void(0)\" onclick=\"parent.left.buyItem('"
+
((DataRowView)container.DataItem)["productnumber"].ToString() +
"', '" + ((DataRowView)container.DataItem)["brand"].ToString() +
"', '" +
((DataRowView)container.DataItem)["productname"].ToString()
+
"', '" + ((DataRowView)container.DataItem)["price"].ToString() +
"');\"><img src='add2.jpg' border=0
onmouseover=this.src='add2mouseover.jpg' onmouseout=this.src='add2.jpg'
title='Click to buy one of this item'></A>";

--- and here is the fast one ---


l.Text = "In brackets[" +
((DataRowView)container.DataItem)["productnumber"].ToString() +
"', '" + ((DataRowView)container.DataItem)["brand"].ToString() +
"', '" +
((DataRowView)container.DataItem)["productname"].ToString()
+
"', '" + ((DataRowView)container.DataItem)["price"].ToString() +
"]";


It doesn't matter whether I use LoadTemplate or inherit from ITemplate and
use new MyTemplateColumn, my template column is still way too slow.

(I tried two methods of adding a template column in code:
http://www.dotnetbips.com/displayarticle.aspx?id=84
which is LoadTemplate from an ascx file, and
http://www.dotnetbips.com/displayarticle.aspx?id=85
which is to roll your own ITemplate, and use New MyTemplateColumn.)

Here is the code which creates the column:

Dim MyTemplate As ITemplate = New MySlowTemplateColumn("brand")
Dim ColumnBuy As TemplateColumn = New TemplateColumn
ColumnBuy.HeaderText = "&nbsp;Buy&nbsp;"
ColumnBuy.ItemTemplate = MyTemplate
NextGrid.Columns.Add(ColumnBuy)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

LoadTemplate is very slow 0

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top