Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are some ASP.NET GridView performance improvement opportunities?

I have an ASP.NET application that is fairly basic. It queries some data and displays the data in a GridView (0 - 2000 or so records possible). I've been trying to find some ways to make it zippier, best practices, etc. as it seems to be a little sluggish while the GridView is being rendered. I've seen some threads on utilizing CSS vs. setting all the styles directly on the GridView, but I'm not sure how this would look.

This is what the GridView looks like right now...

<asp:GridView ID="gvResults" runat="server" DataKeyNames="ORDNO" AutoGenerateColumns="False"
    CellPadding="4" ForeColor="#333333" OnSelectedIndexChanged="gvResults_SelectedIndexChanged"
    Width="100%" OnRowDataBound="gvResults_RowDataBound" meta:resourcekey="gvResultsResource1">
    <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
    <Columns>
        <asp:BoundField DataField="CSTNO" HeaderText="CUST" meta:resourcekey="BoundFieldResource1" />
        <asp:BoundField DataField="ORDNO" HeaderText="RMA NUMBER" meta:resourcekey="BoundFieldResource2" />
        <asp:BoundField DataField="CSTORD" HeaderText="CUST PO NUMBER" meta:resourcekey="BoundFieldResource3" />
        <asp:BoundField DataField="ORDDTE" HeaderText="ORDER DATE" meta:resourcekey="BoundFieldResource4" />
        <asp:BoundField DataField="INVDTE" HeaderText="INVOICE DATE" HtmlEncode="False" meta:resourcekey="BoundFieldResource5" />
        <asp:CommandField ShowSelectButton="true" ButtonType="Link" meta:resourcekey="CommandFieldResource1"  />
    </Columns>
    <EditRowStyle BackColor="#999999" />
    <EmptyDataTemplate>
        <span style="color: Red;">
            <asp:Literal ID="litErrorNoRMAFound" runat="server" EnableViewState="False" meta:resourcekey="litErrorNoRMATagsFoundResource1"
                OnInit="litErrorNoRMAFound_Init"></asp:Literal>
        </span>
    </EmptyDataTemplate>
    <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
    <HeaderStyle BackColor="#3494CC" Font-Bold="True" ForeColor="White" HorizontalAlign="Left" />
    <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
    <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
    <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
</asp:GridView>

Thanks in advance, for any of your ideas/comments.

EDIT
Requirements do not allow for paging of the data. I am also looking for specific information on CSS utilization and the GridView...

like image 463
RSolberg Avatar asked Nov 27 '22 08:11

RSolberg


1 Answers

A few ideas:

  • Eliminate viewstate if possible.
  • If you're using IIS6 or better, consider enabling compression.
  • Enable paging on your GridView to keep request times down.
  • Make sure your deployed production solution is release-compiled with no rogue debugging or tracing directives
like image 79
Dave Swersky Avatar answered Dec 04 '22 00:12

Dave Swersky