Why is my dynamically added TemplCol so slow?

Discussion in 'ASP .Net Datagrid Control' started by Justin Dutoit, Jul 26, 2003.

  1. 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)
    Justin Dutoit, Jul 26, 2003
    #1
    1. Advertising

  2. 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
    "Justin Dutoit" <> wrote in message
    news:...
    > 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)
    >
    >
    >
    Justin Dutoit, Jul 26, 2003
    #2
    1. Advertising

  3. 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" <> wrote in message
    news:e$...
    > Hi
    >
    > Try preloading the images in JavaScript. so that it will be faster.
    >
    > HTH
    > Prasad
    > "Justin Dutoit" <> wrote in message
    > news:#...
    > > 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
    > > "Justin Dutoit" <> wrote in message
    > > news:...
    > > > 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)
    > > >
    > > >
    > > >

    > >
    > >

    >
    >
    Justin Dutoit, Jul 27, 2003
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jeffrey Todd
    Replies:
    1
    Views:
    4,087
    Peter Blum
    Jun 2, 2005
  2. mike
    Replies:
    3
    Views:
    375
    Virgil Green
    Jul 11, 2005
  3. Mr. SweatyFinger

    why why why why why

    Mr. SweatyFinger, Nov 28, 2006, in forum: ASP .Net
    Replies:
    4
    Views:
    853
    Mark Rae
    Dec 21, 2006
  4. Mr. SweatyFinger
    Replies:
    2
    Views:
    1,739
    Smokey Grindel
    Dec 2, 2006
  5. parsifal
    Replies:
    4
    Views:
    636
    Alexey Smirnov
    Mar 15, 2007
Loading...

Share This Page