This is my view . if i open this view it want to load all the list of data which is mention in the below image eg
My VisitorsViewModel model
public DateTime FromDate { get; set; }
public DateTime ToDate { get; set; }
My View_VisitorsForm Model
public System.Guid VisitingID { get; set; }
public string Employee { get; set; }
public string CustomerName { get; set; }
public Nullable VisitingDate { get; set; }
public string StartTime { get; set; }
public string EndTime { get; set; }
public string SpendTime { get; set; }
public string POVisit { get; set; }
so i decided to access two model properties in same view so i call one model property in another model whixch is mentioned in the below model
My VisitorsViewModel model
public DateTime FromDate { get; set; }
public DateTime ToDate { get; set; }
public ICollection Visits { get; set; }
My controller code
public ActionResult displaycustomer()
{
List objvisitlist = (from v in db.View_VisitorsForm select v).ToList();
return View(objvisitlist);
}
This is my Controller code
List objvisitlist = (from v in db.View_VisitorsForm select v).ToList();
this is the query to list all the data.
My view
@model Sample_Customer.View_VisitorsForm
@*@model IEnumerable*@
@{
ViewBag.Title = "DailyVisitReport";
}
Visit Report
@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"})
| Visiting Date | Customer Name | Employee | Purpose of Visit | Contact Person | Description | Next Appointment |
|---|---|---|---|---|---|---|
@Convert.ToString(string.Format("{0:MMM-dd-yyyy}", i.VisitingDate)) | @i.CustomerName | @i.Employee | @i.POVisit | @i.ContactPerson | @i.Description | @Convert.ToString(string.Format("{0:MMM-dd-yyyy}", i.NextAppointment)) |
My doubt is i call the one model (view_visitorsForm) in VisitorsViewmodel by
public ICollection Visits { get; set; }
and i have to list all the data in view when i open the page .so in controller i wrote this code
List objvisitlist = (from v in db.View_VisitorsForm select v).ToList();
Now i created the view by giving model name as VisitorsViewModel. Now my doubt is which object i have to call in the place of ??. so it will display all the data when i open the page..
i tried to explain my issue as per my level best please any one understand my issue and help me to solve this problem.
Advance thanks.
2 Replies
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Sneha KPosted Apr 5, 2016, 1:33 AM
Bharath PeggemPosted Apr 5, 2016, 1:29 AM