This question is locked. New answers and comments are not allowed.
Hi, im using ASP.NET MVC 2 with a Telerik Grid. The grid itself displays the data well enough, and i am using server binding. When i try to go to a different page, Ive discovered that my view data nulls itself.
Here is the databinding part of my grid:
<code> DataBinding(d => d.Server().Select("Index", "Manifest", new {mivm = (ManifestIndexViewModel)ViewData["ManifestIndexSearchModel"], id = -3, postback = 0})) </code>
And the controller action is:
<code>
public ActionResult Index(ManifestIndexViewModel mivm, int id = 0, int postback = 0)
{
var fromDt = mivm.FromDate ?? new DateTime(1900, 1, 1);
var toDt = mivm.ToDate ?? new DateTime(2099, 12, 31);
mivm.DetermineSearchParam();
switch (id)
{
case -3:
break;
case -2:
//Field offices changed
mivm.FacilityId = 0;
break;
case -1:
mivm.FieldOfficeId = 0;
mivm.FacilityId = 0;
//Company changed)
break;
case 0:
//First time on screen
mivm = new ManifestIndexViewModel("",
0,
0,
0,
new DateTime(1900, 1, 1),
new DateTime(2099, 12, 31),
_icdp.GetAllCompanies(),
_ifodp.GetAllFieldOffices(),
_ifdp.GetAllFacilities());
break;
case 1:
if (mivm.ManifestPartialId == "" &&
mivm.CompanyId == 0 && mivm.FieldOfficeId == 0 && mivm.FacilityId == 0 &&
fromDt == new DateTime(1900, 1, 1) && toDt == new DateTime(2099, 12, 31))
{
id = 0;
}
else
{
mivm.Manifests = _imdp.GetManifestByViewModel(mivm);
}
break;
default:
break;
}
//Will always have to reset the lists.
mivm.Companies = _icdp.GetAllCompanies();
mivm.FieldOffices = _ifodp.GetFieldOfficesForCompany(mivm.CompanyId);
mivm.Facilities = _ifdp.GetFacilityForFieldOffice(mivm.FieldOfficeId);
ViewData["ManifestIndexSearchModel"] = mivm ?? null;
return View(mivm);
}
</code>
I cant quite track the problem. Any insights?
Here is the databinding part of my grid:
<code> DataBinding(d => d.Server().Select("Index", "Manifest", new {mivm = (ManifestIndexViewModel)ViewData["ManifestIndexSearchModel"], id = -3, postback = 0})) </code>
And the controller action is:
<code>
public ActionResult Index(ManifestIndexViewModel mivm, int id = 0, int postback = 0)
{
var fromDt = mivm.FromDate ?? new DateTime(1900, 1, 1);
var toDt = mivm.ToDate ?? new DateTime(2099, 12, 31);
mivm.DetermineSearchParam();
switch (id)
{
case -3:
break;
case -2:
//Field offices changed
mivm.FacilityId = 0;
break;
case -1:
mivm.FieldOfficeId = 0;
mivm.FacilityId = 0;
//Company changed)
break;
case 0:
//First time on screen
mivm = new ManifestIndexViewModel("",
0,
0,
0,
new DateTime(1900, 1, 1),
new DateTime(2099, 12, 31),
_icdp.GetAllCompanies(),
_ifodp.GetAllFieldOffices(),
_ifdp.GetAllFacilities());
break;
case 1:
if (mivm.ManifestPartialId == "" &&
mivm.CompanyId == 0 && mivm.FieldOfficeId == 0 && mivm.FacilityId == 0 &&
fromDt == new DateTime(1900, 1, 1) && toDt == new DateTime(2099, 12, 31))
{
id = 0;
}
else
{
mivm.Manifests = _imdp.GetManifestByViewModel(mivm);
}
break;
default:
break;
}
//Will always have to reset the lists.
mivm.Companies = _icdp.GetAllCompanies();
mivm.FieldOffices = _ifodp.GetFieldOfficesForCompany(mivm.CompanyId);
mivm.Facilities = _ifdp.GetFacilityForFieldOffice(mivm.FieldOfficeId);
ViewData["ManifestIndexSearchModel"] = mivm ?? null;
return View(mivm);
}
</code>
I cant quite track the problem. Any insights?