Click here to Skip to main content
16,019,435 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
Posted
Comments
Pooja Dhanani 22-Oct-13 3:38am    
I thought, when you set Model = new ICCEntities();Batting and Bowling property not get initialize.
Ruter11 22-Oct-13 4:21am    
yes i am not loading model on page load please let me know how to do that
Pooja Dhanani 22-Oct-13 4:53am    
In ICCEntites class constructor initialize Batting and Bowling List as per it's types. So that it does not reference to null value.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900