Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8371023
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T14:03:42+00:00 2026-06-09T14:03:42+00:00

Basically I need help improving the performance of a page full of gridviews to

  • 0

Basically I need help improving the performance of a page full of gridviews to reduce the amount of C# and move as many GridView settings into the ASP Code (not the data itself, that’s bound at run time and needs to stay in the C#).

I’m relatively new to the GridView control and need help moving the settings into the GridView, as the page this code is on will have about 8 or 9 tables.

Here’s my ASP code:

<asp:GridView runat="server" ID="tblBasicProcessingTime"
    Caption="Basic Processing Stats" ShowHeader="False">
</asp:GridView>

And my C# Code:

var longestTime = ReportData.OrderByDescending(x => x.TimeSpentProcessing).FirstOrDefault();
var averageTime = ReportData.Average(x => x.TimeSpentProcessing);
var shortestTime = ReportData.OrderBy(x => x.TimeSpentProcessing).FirstOrDefault();

var table = new DataTable();

const string col1Name = "Header";
const string col2Name = "Data";

table.Columns.Add(col1Name);
table.Columns.Add(col2Name);

var row1 = table.NewRow();
row1[col1Name] = "Longest Processing Time";
row1[col2Name] = longestTime.TimeSpentProcessing;
table.Rows.Add(row1);

var row2 = table.NewRow();
row2[col1Name] = "Average Processing Time";
row2[col2Name] = averageTime;
table.Rows.Add(row2);

var row3 = table.NewRow();
row3[col1Name] = "Shortest Processing Time";
row3[col2Name] = shortestTime.TimeSpentProcessing;
table.Rows.Add(row3);

tblBasicProcessingTime.DataSource = table;
tblBasicProcessingTime.DataBind();

Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T14:03:43+00:00Added an answer on June 9, 2026 at 2:03 pm
    <asp:GridView
                ID="gvList"
                runat="server"
                AutoGenerateColumns="False"
                EnableModelValidation="True"
                HeaderStyle-HorizontalAlign="Center"
                Width="100%"
                RowStyle-Height="25px"
                HeaderStyle-CssClass="ui-th-div-ie"
                RowStyle-CssClass="TR_ROW1"
                AlternatingRowStyle-CssClass="TR_ROW2"
                HeaderStyle-ForeColor="#0073ea"
                BorderWidth="1px"
                CellPadding="2"
                HorizontalAlign="Center"
                OnPageIndexChanging="gvList_PageIndexChanging"
                AllowPaging="true"
                AllowSorting="true"
                PagerStyle-HorizontalAlign="Right"
                PageSize="1"
                OnSorting="gvList_Sorting">
    
                <Columns>
                    <asp:TemplateField HeaderStyle-Width="20%" HeaderText="<%$ Resources: CommonResources, lbl_InstoreHistLotNo.Text %>" SortExpression="LotNo">
                        <ItemTemplate>
                            <asp:Label ID="lbl_InstoreHistLotNo" runat="server" Text='<%#Eval("LotNo")%>'></asp:Label>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderStyle-Width="10%" HeaderText="<%$ Resources: CommonResources, lbl_InstoreHistPartNo.Text %>" SortExpression="PartCode">
                        <ItemTemplate>
                            <asp:Label ID="lbl_InstoreHistPartNo" runat="server" Text='<%#Eval("PartCode")%>'></asp:Label>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderStyle-Width="10%" HeaderText="<%$ Resources: CommonResources, lbl_InstoreHistPartName.Text %>" SortExpression="PartName">
                        <ItemTemplate>
                                <asp:Label ID="lbl_InstoreHistPartName" runat="server" Text='<%#Eval("PartName")%>'/>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderStyle-Width="10%" HeaderText="<%$ Resources: CommonResources, lbl_InstoreHistInQuality.Text %>" SortExpression="Quality">
                        <ItemStyle HorizontalAlign="Right" />
                        <ItemTemplate>
                                <asp:Label ID="lbl_InstoreHistInQuality" runat="server" Text='<%#Eval("Quality")%>'/>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderStyle-Width="10%" HeaderText="<%$ Resources: CommonResources, lbl_InstoreHistInUsercode.Text %>" SortExpression="UserCode">
                        <ItemTemplate>
                            <asp:Label ID="lbl_InstoreHistInUsercode" runat="server" Text='<%#Eval("UserCode")%>'/>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderStyle-Width="15%" HeaderText="<%$ Resources: CommonResources, lbl_InstoreHistInTime.Text %>" SortExpression="InStoreDate">
                    </asp:TemplateField>
                </Columns>
                <PagerStyle HorizontalAlign="Left"   />
                <PagerSettings Position="TopAndBottom" Mode="Numeric" />
            </asp:GridView>
    

    This is just a simple demo for gridview databind.
    However, my header text is loading from resource file, you can set by yourself, like string “aaa”, “bbb”, “ccc”

    In the back end , your code may like this:

    DataTable dt = SqlHelper.ExcuteDataSet("select * from InStoreHistory");
    gvList.DataSource = dt;
    gvList.DataBind();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have run into a blocking scenario and need help. The problem is basically
I need help with auto-saving a textarea. Basically, whenever a user is typing in
I just need help. Basically I am creating a windows appllication that sends bulk
I need little help for url rewriting in wordpress. basically what i need: mydomain.com/mysomewordpresspost
I need some help choosing databases for my application. My web application will basically
I need help validating an input's value against the current date. Basically i need
I need help with this batch file I'm working on, Basically everytime it does
I need help with the following... var timer:Timer = new Timer(x); basically x is
Been trying this for quite a while now and I need help. Basically I
I have a script, which basically looks like this (the part I need help

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.