Painfully slow GridView when using ItemTemplates and EditItemTemplates!

Discussion in 'ASP .Net Datagrid Control' started by Robert Pettersson, Nov 20, 2006.

  1. Hi,

    I have a old ASP-page I´m updating to ASP.Net 2.0. In my old ASP-page I
    generated a table, looping through my recordset.
    For that amount of rows it was very fast.

    Now I´m using a GridView to present my result. But the problem is that I
    need to be able to edit my rows.
    So I created ItemTemplates, CommandField and events to be able to do so. It
    works fine on a small resultset, but on a larger resultset it is painfully
    slow!!
    So I tried just throwing out a GridView and connecting it to the same
    result, with BoundFields. And then it´s mush faster!

    The resultset I´m trying to present is 6000 records. And the Gridview with
    bound columns take ~40seconds, and the one with ItemTemplates take like 10
    minutes!
    And when I press the CommandField (my button) to edit, it takes another 10
    minutes to go to edit mode. Why are the postbacks so slow? Do the client
    redraw it eveytime? Is the only way not to redraw the whole page to use
    AJAX?

    The problem is not in the database, the SP I´m running takes 1 second to
    execute. It is presenting the data on the client!

    My old ASP-page was faster the both GridView alternatives!! How can that be?

    How do I solve this? Can you not have Editable GridViews in ASP.Net that
    have a larger resultset?????

    Would be very greateful for any help!!!!

    This is part of my 2 Gridviews:

    ItemTemplates (really slow!):

    <asp:GridView ID="GridViewContribWithdraw" runat="server"
    AllowSorting="True" EnableViewState="false"
    AutoGenerateColumns="False" AllowPaging="False" PageSize="50"
    DataKeyNames="pkTransactionID"
    OnPageIndexChanging="GridViewContribWithdraw_PageIndexChanging"
    OnRowCancelingEdit="GridViewContribWithdraw_RowCancelingEdit"
    OnRowEditing="GridViewContribWithdraw_RowEditing"
    OnSorting="GridViewContribWithdraw_Sorting"
    OnRowUpdating="GridViewContribWithdraw_RowUpdating">
    <Columns>
    <asp:TemplateField HeaderText="pkTransactionID"
    SortExpression="pkTransactionID"
    Visible="False">
    <EditItemTemplate>
    <asp:Label ID="pkTransactionID" runat="server" Text='<%#
    Bind("pkTransactionID") %>'></asp:Label>
    </EditItemTemplate>
    <ItemTemplate>
    <asp:Label ID="LabelpkTransactionID" runat="server"
    Text='<%# Eval("pkTransactionID") %>'></asp:Label>
    </ItemTemplate>
    </asp:TemplateField>
    <asp:TemplateField HeaderText="Imported"
    SortExpression="ImportTypeName">
    <EditItemTemplate>
    <asp:DropDownList ID="ImportType" AutoPostBack="false"
    SelectedValue='<%# Eval("ImportType") %>' runat="server" DataSource='<%#
    GetImportTypes() %>' DataTextField="Value" DataValueField="Key">
    </asp:DropDownList>
    </EditItemTemplate>
    <ItemTemplate>
    <asp:Label ID="LabelImported" runat="server" Text='<%#
    Eval("ImportTypeName") %>'></asp:Label>
    </ItemTemplate>
    </asp:TemplateField>
    <asp:CommandField ButtonType="Button" ShowEditButton="True">
    <ControlStyle CssClass="car-button" />
    </asp:CommandField>
    </Columns>
    <PagerSettings Position="TopAndBottom" />
    </asp:GridView>

    Boundfields (mush faster):

    <asp:GridView ID="GridViewContribWithDrawRead" EnableViewState="false"
    runat="server" AutoGenerateColumns="False">
    <Columns>
    <asp:BoundField DataField="ImportTypeName"
    HeaderText="Imported"/>
    <asp:BoundField DataField="PortfolioCode"
    HeaderText="Portfolio"/>
    <asp:BoundField DataField="OriginID" HeaderText="OriginID"
    SortExpression="OriginID" />
    <asp:BoundField DataField="TranTypeDescription"
    HeaderText="TranType"/>
    </Columns>
    </asp:GridView>

    /Robert
    Robert Pettersson, Nov 20, 2006
    #1
    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. Marc Castrechini
    Replies:
    3
    Views:
    2,472
    Marc Castrechini
    Jul 15, 2004
  2. =?Utf-8?B?V2ViTWF0cml4?=

    DataList EditCommand displaying Different EditItemTemplates

    =?Utf-8?B?V2ViTWF0cml4?=, Mar 14, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    1,199
    =?Utf-8?B?V2ViTWF0cml4?=
    Mar 14, 2006
  3. emp
    Replies:
    3
    Views:
    851
  4. Mufasa

    TreeView is painfully slow.

    Mufasa, Jun 11, 2007, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    174
    lwhitb1
    Jun 11, 2007
  5. Bill
    Replies:
    1
    Views:
    121
Loading...

Share This Page