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 i
Here is, accoring to your change, how I would do that :
public static Customers GetAllCustomer(int startIndex, int nbrOfResults, out total) {
Customers customers = new Customers();
NShop_SmallEntities data = new NShop_SmallEntities();
var dbCustomers = from c in data.Customers
select c;
// Retreiving total number of customers. NEEDED to get
// ObjectDataSource working.
total = dbCustomers.Count();
foreach (var dbCustomer in dbCustomers
.Skip((startIndex * nbrOfResults) + 1)
.Take(NumberOfResults).ToList() {
customers.Add(Customer.GetCustomer(dbCustomer));
}
return customers;
}
///
/// This methods must have the same signature than the "real" one... exept the name :oP
///
public static int GetAllCustomerCount(int startIndex, int nbrOfResults, out total) {
return (from c in data.Customers select c).Count();
}
And now in your page ;