using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Services;

public partial class _Default : System.Web.UI.Page 
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    [WebMethod]
    public static Dictionary<string, object> GetDataAndCount(int startRowIndex, int maximumRows, string sortExpression, string filterExpression, string myCustomField)
    {
        Dictionary<string, object> result = new Dictionary<string, object>();
        List<MyObject> data = Fill();

        result["Count"] = data.Count;
        result["Data"] = data.Skip(startRowIndex).Take(maximumRows).ToList();
        return result;
    }

    private static List<MyObject> Fill()
    {
        var data = new List<MyObject>();
        for (int i = 1; i < 100; i++)
        {
            data.Add(new MyObject { ID=i,Text="Text " + i});
        }
        return data;
    }

    public class MyObject
    {
        public int ID { get; set; }
        public string Text { get; set; }
    }
}
