1
Answer

How to return 2 grids data on one Action Result in MVC

Gaurav Kapahi

Gaurav Kapahi

11y
1.1k
1
View

@{Html.RenderPartial("BattingGridPartial", Model.Batting);

@{Html.RenderPartial("BowlingGridPartial", Model.Bowling);

Controller

[HttpPost]
        public ActionResult LoadGrid()
        {
           
            var Model = new ICCEntities();
            Model = null;
            try
            {
                string r;
                r = Session["Report"].ToString();
                IEnumerable<string> SelectedReportId = r.Split(',');
                IEnumerator<string> ReportIds = SelectedReportId.GetEnumerator();

                while (ReportIds.MoveNext())
                {
                    if (ReportIds.Current == "1")
                    {
                        Model = new ICCEntities();
                        Session["ReportId"] = "1";
                                                                       
                        Model.Batting = GetList();

                      
                    }

                    if (ReportIds.Current == "2")
                    {
                        Session["ReportId"] = "2";

                        Model.Bowling = GetList();
 
                    }

                     }
            catch
            {
            }
         
           return View(Model);
}


Model

  public List<IDictionary> Batting { get; set; }
        public List<IDictionary> Bowling { get; set; }


I am able to fetch data in to Model in controller but it is not returning any grid in view... On load it is giving me error object reference is null in Model.Bowling in View, Please Help me in Same
Answers (1)
Next Recommended Forum