| <script type="text/javascript"> $(function () { // the datasource "window.gridData" is referred from jsondata.min.js var data = ej.DataManager(window.gridData).executeLocal(ej.Query().take(50)); $("#Grid").ejGrid({ dataSource: ej.DataManager({ url: "/Home/DataSource/?myparam=WELLI", adaptor: "UrlAdaptor" }), allowPaging: true, toolbarSettings: { showToolbar: true, toolbarItems: [ej.Grid.ToolBarItems.Add, ej.Grid.ToolBarItems.Edit, ej.Grid.ToolBarItems.Delete, ej.Grid.ToolBarItems.Update, ej.Grid.ToolBarItems.Cancel, ej.Grid.ToolBarItems.Search ] }, allowSearching:true, columns: [ { field: "OrderID", isPrimaryKey: true }, { field: "CustomerID" }, ] }); }); </script> Serverside:- public ActionResult DataSource(DataManager dm,string myparam) { DataOperations operation = new DataOperations(); int count; DataTable dt = new DataTable("Order"); string constring = ConfigurationManager.ConnectionStrings["NORTHWNDConnectionString"].ConnectionString; using (SqlConnection con = new SqlConnection(constring)) { using (SqlCommand cmd = new SqlCommand("CustOrdersOrders", con)) { cmd.CommandType = CommandType.StoredProcedure; //implementing the stored procedure cmd.Parameters.AddWithValue("@CustomerID",myparam); con.Open(); SqlDataReader dr = cmd.ExecuteReader(); dt.Load(dr); // Load into the dataTable dr.Close(); con.Close(); } } //Convet the dataTable into list List<EditableOrder> resList = new List<EditableOrder>(); resList = (from DataRow dr in dt.Rows select new EditableOrder() { OrderID = Convert.ToInt32(dr["OrderID"]), CustomerID = dr["CustomerID"].ToString(), EmployeeID = Convert.ToInt32(dr["EmployeeID"]), Freight = Convert.ToDecimal(dr["Freight"]), }).ToList(); count = resList.Count; return Json(new { result = resList, count = count }, JsonRequestBehavior.AllowGet); //return the data in the form of result and count pairs in url adaptor } Stored procedure:- CREATE PROCEDURE CustOrdersOrders @CustomerID nchar(5) AS SELECT OrderID, CustomerID, EmployeeID,Freight, OrderDate, RequiredDate, ShippedDate FROM Orders WHERE CustomerID = @CustomerID ORDER BY OrderID |