从另一个方法中分配访问列表值; C#MVC

时间:2015-01-19 12:12:03

标签: c# asp.net-mvc kendo-grid

我在控制器中定义了变量列表effectedCourseInstances,并在ProcessCourseApplicationURL()方法中为其赋值,但在从视图往返后,列表不再保持值null 。我想确保我可以在effectedCourseInstances方法中访问指定的值GetAllProcessedURLCourses()。我在哪里做错????

public class CourseManagementController : Controller
{
  private List<CourseInstanceModel> _effectedCourseInstances;

  [HttpPost]
  public ActionResult ProcessCourseApplicationURL(CourseApplicationsURLFeed_Model obj)
  {
    try
    {
      if (ModelState.IsValid)
      {
        _effectedCourseInstances = _coursesServices.ProcessAllCoursesApplicationURL(obj);
      }
    }
    catch (DataException ex)
    {
      ModelState.AddModelError("", "Unable To Process Courses Application URL from CID DB" + ex);
    }
    return PartialView("CourseApplicationURLTest_Partial", _effectedCourseInstances);
  } //end

  public ActionResult GetAllProcessedURLCourses([DataSourceRequest]DataSourceRequest request)
  {
    DataSourceResult CourseInstances_Feed_Result = _effectedCourseInstances.ToDataSourceResult(request);
    return Json(CourseInstances_Feed_Result, JsonRequestBehavior.AllowGet);
  }
}

0 个答案:

没有答案