This question is locked. New answers and comments are not allowed.
Hello.
i have this object that i created with LinqToSql
Employee
- ID
- Name
- DateOfBirth
- CompanyMainID -> this is where the problem occurs. LinqToSql creates a collection of CompanyMain in this object.
When i return the collection as the Model to the View (NOT USING AJAX)
and use this in my GRID
it works perfect.
when i try to incorporate ajax the Grid
i have this object that i created with LinqToSql
Employee
- ID
- Name
- DateOfBirth
- CompanyMainID -> this is where the problem occurs. LinqToSql creates a collection of CompanyMain in this object.
When i return the collection as the Model to the View (NOT USING AJAX)
IEnumerable<Employee> employee = ctx.Employee.ToList()View(employee)@model IEnumerable<Employee>@(Html.Telerik().Grid(Model).Name("Grid").Columns(columns=>{columns.bound(o=>o.Name);columns.bound(o=>o.DateOfBirth);})....etc etcit works perfect.
when i try to incorporate ajax the Grid
[GridAction]
public ActionResult _AjaxBinding(){
IEnumerable<Employee> employees;using(DataContext ctx = new DataContext){employees = ctx.Employee.ToList()}return View(new GridModel<Employee>(){Data=employees});
}THE VIEW and GRID
@model GridModel<Employee>@(Html.Telerik().Grid<Employee>().Name("Grid").Columns(columns=>{columns.bound(o=>o.Name);columns.bound(o=>o.DateOfBirth);}).DataBindings(b=>b.Ajax().Select("_AjaxBinding","Home"))....etc etcgoes all the way in the collection of Employees and tries to pull the collection of companies. Of course this throw an exception since the DataContext has been already disposed and can't pull that collection.
Does anyone have come across this issue before?
Thanks