using System.Collections.Generic;
using System.Linq;
using ProductsModel;

public partial class Default2 : System.Web.UI.Page
{
    static readonly int PageSize = 80;

    [System.Web.Services.WebMethod]
    public static System.Collections.IEnumerable GetProducts(int startIndex)
    {
        startIndex = startIndex * PageSize;
        using (var db = new ProductsEntities())
        {
            return db.Products.Select(p => new { p.ProductID, p.ProductNumber, p.Name, p.ListPrice, p.Weight })
                              .OrderBy(p => p.ProductID)
                              .Skip(startIndex).Take(PageSize)
                              .ToList();
        }
    }

    protected override void OnLoad(System.EventArgs e)
    {
        base.OnLoad(e);
        if (!IsPostBack)
        {
            RadListView1.DataSource = GetProducts(0);
            RadListView1.DataBind();
        }
    }
}