Note that there are some explanatory texts on larger screens.

plurals
  1. POBind GridView with many records
    text
    copied!<p>I have a GridView which shows only 50 records at a time through paging. If i bind that to a source say containing 150 records, it works like charm but when the record size increases drastically to 10,00000, it took ages to load data.. So, i want to know is there any way of just loading 50 records at a time which are visible??</p> <blockquote> <p><strong>I want something like Lazy Loading or the feature of Virtualizing Stack Panel in wpf.</strong></p> </blockquote> <p>This is how i am binding to the GridView - </p> <pre><code>private void LoadCustomers() { if (Cache["CustomersData"] == null) { Business.Customers customers = Business.Customers.GetAllCustomer(); Cache["CustomersData"] = customers; } this.customerGridView.DataSource = Cache["CustomersData"]; this.customerGridView.DataBind(); } </code></pre> <p>And here's the function which fetch data from DB- </p> <pre><code>public static Customers GetAllCustomer(int index) { Customers customers = new Customers(); NShop_SmallEntities data = new NShop_SmallEntities(); var dbCustomers = (from c in data.Customers select c).OrderBy(c=&gt; c.CustomerId).Skip(index * 50).Take(50); foreach (var dbCustomer in dbCustomers) { customers.Add(Customer.GetCustomer(dbCustomer)); } return customers; } public static Customer GetCustomer(DAL.Customer dbCustomer) { return new Customer() { CustomerId = dbCustomer.CustomerId, FirstName = dbCustomer.FirstName, LastName = dbCustomer.LastName, Email = dbCustomer.Email, DOB = dbCustomer.DOB, City = dbCustomer.City, State = dbCustomer.State, PostalCode = dbCustomer.PostalCode, Country = dbCustomer.Country, OrderCount = dbCustomer.Orders.Count() }; } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload