Tech
Forums
Jobs
Books
Events
Live
Interviews
More
Learn
Training
Career
Members
Videos
News
Blogs
Login
Sign Up
Ask Question
6
Reply
Multiple Models in Single View in MVC
ceci bela
Aug 8 2014 3:11 PM
933
Reply
Hello, I am trying to replicated this http://www.c-sharpcorner.com/UploadFile/ff2f08/multiple-models-in-single-view-in-mvc/Default.aspx for my project but I am unable to load the data from database.
In that example it gets all the faculty and students this way
private
List
<
Teacher
> GetTeachers()
{
List
<
Teacher
> teachers =
new
List
<
Teacher
>();
teachers.Add(
new
Teacher
{ TeacherId = 1, Code =
"TT"
, Name =
"Tejas Trivedi"
});
teachers.Add(
new
Teacher
{ TeacherId = 2, Code =
"JT"
, Name =
"Jignesh Trivedi"
});
teachers.Add(
new
Teacher
{ TeacherId = 3, Code =
"RT"
, Name =
"Rakesh Trivedi"
});
return
teachers;
}
Assuming that I also have
public
class
Teacher / Student class
How could I load the values from the database?
private
List
<
Teacher
> GetTeachers()
{
DBContextEntities db = new DBContextEntities();
List
<
Teacher
> teachers =
new
List
<
Teacher
>();
????
return
teachers;
}
Upload Source Code
Select only zip and rar file.
Post
Reset
Cancel
Answers (
6
)
Next Recommended Forum
Export Gridview and image to excel Report
ONE ASP.NET identity system