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 8253593
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T00:55:50+00:00 2026-06-08T00:55:50+00:00

I have a large amount of data (a sql query with 20000 records) and

  • 0

I have a large amount of data (a sql query with 20000 records) and filling my datagrid with that amount of data takes like 10 minutes, this is my gridview definition:

<asp:GridView ID="g" runat="server" Height="113px" Width="817px" 
BackColor="White" BorderColor="#999999" BorderStyle="None" BorderWidth="1px" 
CellPadding="3" GridLines="Vertical" AllowPaging="True" Font-Size="Small" 
     PageSize="30">
    <AlternatingRowStyle BackColor="#DCDCDC" />
    <FooterStyle BackColor="#CCCCCC" ForeColor="Black" />
    <HeaderStyle BackColor="#000084" Font-Bold="True" ForeColor="White" />
    <PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" />
    <RowStyle BackColor="#EEEEEE" ForeColor="Black" />
    <SelectedRowStyle BackColor="#008A8C" Font-Bold="True" ForeColor="White" />
    <SortedAscendingCellStyle BackColor="#F1F1F1" />
    <SortedAscendingHeaderStyle BackColor="#0000A9" />
    <SortedDescendingCellStyle BackColor="#CAC9C9" />
    <SortedDescendingHeaderStyle BackColor="#000065" />
    <PagerStyle cssClass="gridpager" HorizontalAlign="Left" />  

</asp:GridView>

As you can see I have enabled to true the AllowPaging property.

This is how I bind the data:

DataSet dts = new DataSet();
OracleDataAdapter oad = new OracleDataAdapter(query, co.conn);

cmd.CommandText = query;
cmd.CommandType = CommandType.Text;

cmd.CommandText = query;
cmd.CommandType = CommandType.Text;
OracleDataReader reader = cmd.ExecuteReader();

oad.Fill(dts);


g.DataSource = dts.Tables[0];
g.DataBind();

How can I improve the performance?

When I fill the dataset (oad.Fill(dts);) takes 10 minutes to complete. Is this because I set the 20000 records at once? Is there a way to show only the first 30 records and recall the data when the user paginates the gridview? Is there another way to improve the performance?

  • 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-08T00:55:52+00:00Added an answer on June 8, 2026 at 12:55 am

    If my understanding is correct, you want to add server paging

    When you simply add AllowPaging="True" to the grid, by default, the GridView has no idea how to paging your data from the server, the paging is being executed in-memory after the whole results have been fetched from the database and this happens every time the GridView is bind

    I think you want to add server paging (paging in the server and only sending to the client a small bunch of records), in order to do that, you could take advantage of the several ASP.Net data source controls.

    Since you are doing the connection to your database manually, then you need to manually add paging code in your queries and map that code to the control

    I think the only data source controls that can help you (since you are using Oracle as the database) are

    • SqlDataSource. Sadly it does not support server paging out-of-the-box, you would need to tweak it
    • ObjectDataSource. It can be easily integrated with the GridView control to provide paging, however you would need to manually add code to your queries or store procedures to paginate your data in the server
    • EntityDatasource. It’s used to connect with your database when using EntityFramework

    If you would be using EF or NHibernate for example, it would be easier, the code would look like:

    g.DataSource = myContext.MyTable.Skip(pageIndex * pageSize).Take(pageSize);
    g.DataBind();
    

    Example using the ObjectDatasource

    ASPX

        <asp:ObjectDataSource runat="server" ID="ods" TypeName="MyObject" EnablePaging="True"
            SelectMethod="FindPaging"
            MaximumRowsParameterName="pageSize"
            SortParameterName="sortColumn"
            StartRowIndexParameterName="startIndex"
            SelectCountMethod="FindPagingCount" onselected="ods_Selected"
        >
            <SelectParameters>
                <asp:Parameter Name="sortColumn" Type="String" />
                <asp:Parameter Name="startIndex" Type="Int32" />
                <asp:Parameter Name="pageSize" Type="Int32" />
            </SelectParameters>
        </asp:ObjectDataSource>
    
                <asp:GridView ID="grid" runat="server" AllowPaging="True" AllowSorting="True" PageSize="10"
                    DataSourceID="ods" AutoGenerateColumns="true">
                </asp:GridView>
    

    Data Component

    [System.ComponentModel.DataObject]
    public class MyObject
    {
        [System.ComponentModel.DataObjectMethod(System.ComponentModel.DataObjectMethodType.Select)]
        public IEnumerable<employee> FindPaging(int startIndex, int pageSize, string sortColumn)
        {
            // place here your code to access your database and use the parameters to paginate your results in the server
        }
    
        [System.ComponentModel.DataObjectMethod(System.ComponentModel.DataObjectMethodType.Select)]
        public int FindPagingCount(int startIndex, int pageSize, string sortColumn)
        {
            var c = new DataClassesDataContext();
    
            return c.employees.Count();
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a large amount of data to sort and query, and I can't
I have a rather large amount of data (100 MB or so), that I
I have a WCF service that can return large amount of data depending on
I have a windows service that receives a large amount of data that needs
I have currently have a web application that caches a large amount of data
I have a SQL Server database with a large amount of data (65 million
I have a large amount of data in a database. When I attempt to
I have a table with large amount of data and want to take too
I have a highly formatted file with large amount of data which I used
I have a simulation in which I need to dump large amount of data,

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.