Hi I want to return a list to view using json. I will explain my issue with eg.
I have 2 fields FromDate ,ToDate and one button in my view. if i select the FromDate ,ToDate and click the button means it want to diaplay the data in the same view based Date Selection
Example Output
I want same as like which is mentioned in the above image . That is if i select the From Date and To Date and Click the search button it want to display the fields based on selection.
My View Model
public string EmployeeName { get; set; }
public string CustomerName { get; set; }
public string CustomerName { get; set; }
public string POVisit { get; set; }
public string ContactPerson { get; set; }
public Nullable NextAppointmnet { get; set; }
public string Description { get; set; }
public DateTime FromDate { get; set; }
public DateTime ToDate { get; set; }
public string Description { get; set; }
public DateTime FromDate { get; set; }
public DateTime ToDate { get; set; }
My Controller
public ActionResult DailyVisitReport()
{
return View();
}
public JsonResult GetDatesfromFromDateToDate(string fromdate, string Todate,VisitorsViewModel vvm)
{
DateTime fromdt = Convert.ToDateTime(fromdate);
DateTime todt = Convert.ToDateTime(Todate);
List VisitEntry = (from v in db.View_VisitorsForm where v.VisitingDate <= fromdt && v.VisitingDate >=todt select v).ToList();
{
return View();
}
public JsonResult GetDatesfromFromDateToDate(string fromdate, string Todate,VisitorsViewModel vvm)
{
DateTime fromdt = Convert.ToDateTime(fromdate);
DateTime todt = Convert.ToDateTime(Todate);
List
return Json(VisitEntry,JsonRequestBehavior.AllowGet);
}
}
Here i got the From Date and To Date Value and list the data using query as per FromDate and ToDate Criteria . Now my issue i donno how to return these list of data to view from Controller
My View
@Html.LabelFor(model => model.FromDate)
@Html.TextBoxFor(model => model.FromDate, new { @class = "form-control", type = "text" })
@Html.LabelFor(model => model.ToDate)
@Html.TextBoxFor(model => model.ToDate, new { @class = "form-control", type = "text" })
@Html.TextBoxFor(model => model.ToDate, new { @class = "form-control", type = "text" })
My j query code
Please any one tell me the solution to resolve this issue . I tried my level best to explain my issue .please any one understand and give me the solution..
Advance Thanks..
Bharath PeggemPosted Apr 5, 2016, 4:48 AM
Sneha KPosted Apr 5, 2016, 3:53 AM
The parameters dictionary contains a null entry for parameter 'toDate' of non-nullable type 'System.DateTime' for method 'System.Web.Mvc.ActionResult GetDatesfromFromDateToDate(System.DateTime, System.DateTime)' in 'Sample_Customer.Controllers.ReportController'. An optional parameter must be a reference type, a nullable type, or be declared as an optional parameter.
Parameter name: parameters
Sneha KPosted Apr 5, 2016, 12:47 AM
Bharath PeggemPosted Apr 5, 2016, 12:45 AM
Sneha KPosted Apr 4, 2016, 9:26 AM
@Html.TextBoxFor(model => model.ToDate, new { @class = "form-control", type = "text" })
Sneha KPosted Apr 4, 2016, 9:05 AM
Bharath PeggemPosted Apr 4, 2016, 8:53 AM
Sneha KPosted Apr 1, 2016, 9:13 AM
Bharath PeggemPosted Apr 1, 2016, 6:34 AM