TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Ramsès Zogning II
NA
84
20.9k
Multiple Models in Single View in MVC 4 / 5
Jan 27 2015 10:16 AM
Hello,
I am trying to create a web application mvc asp dotnet 4 razor.
I would like to put multiple views in a model.
To make it clearer, here is my Model, my eyesight and my controller.
My Model:
two tables : Malades and Consultations
public DbSet<Malade> Malades { get; set; }
public DbSet<Consultation> Consultations { get; set; }
My Controller:
public ActionResult Index()
{
if (User.Identity.IsAuthenticated)
{
return View();
}
return RedirectToAction("Login", "Account");
}
My ContentViewModel:
public class ViewModelProfil
{
public List<Malade> Malades { get; set; }
public List<Consultation> Consultations { get; set; }
}
My view:
...
@foreach(var item in Model.Malades)
{
@Html.DisplayNameFor(modelItem => item.Nom)
}
@foreach(var item in Model.Consultations)
{
@Html.DisplayNameFor(modelItem => item.Nombre)
}
...
I want to clarify that the data is not manually integrate into the database, but it is a user who filled out a form for the data to be stored in the database.
I did several searches su google, but I fall on tutorials that show how to do it perfectly, but the data are filled manually (Example :
http://www.codeproject.com/Articles/687061/Multiple-Models-in-a-View-in-ASP-NET-MVC-MVC
).
Thank you for your help.
Reply
Answers (
6
)
how to show image in grid view..?
Here I want to create JOBNO for my application in clientside