I am not sure what is wrong I have checked and it looks everything is correct check my model class my controller code my View and my table
My Table is
- public class SemestersController : Controller
- {
- private DatabaseContext db = new DatabaseContext();
- // GET: Semesters
- public ActionResult Index()
- {
- var semesters = db.Semesters.Include(s => s.Programs).Include(s => s.years);
- return View(semesters.ToList());
- }
- // GET: Semesters/Details/5
- public ActionResult Details(int? id)
- {
- if (id == null)
- {
- return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
- }
- Semester semester = db.Semesters.Find(id);
- if (semester == null)
- {
- return HttpNotFound();
- }
- return View(semester);
- }
- }
- }
- @model IEnumerable
- @{
- ViewBag.Title = "Index";
- Layout = "~/Views/Shared/_LayoutStudent.cshtml";
- }
Index
- @Html.ActionLink("Create New", "Create")
class="table">
- @Html.DisplayNameFor(model => model.Programs.Program_Title)
- @Html.DisplayNameFor(model => model.years.Name)
- @Html.DisplayNameFor(model => model.Semester_Title)
- @Html.DisplayNameFor(model => model.Semester_Code)
- @Html.DisplayNameFor(model => model.Semester_Duration_In_Weeks)
- @Html.DisplayNameFor(model => model.Status)
- @Html.DisplayNameFor(model => model.Semester_Start_Date)
- @Html.DisplayNameFor(model => model.Semester_End_Date)
- @Html.DisplayNameFor(model => model.Semester_Credit_Hours)
- @Html.DisplayNameFor(model => model.Date_Created)
- @Html.DisplayNameFor(model => model.Date_Modified)
- @Html.DisplayNameFor(model => model.Added_By)
- @foreach (var item in Model) {
- @Html.DisplayFor(modelItem => item.Programs.Program_Title)
- @Html.DisplayFor(modelItem => item.years.Name)
- @Html.DisplayFor(modelItem => item.Semester_Title)
- @Html.DisplayFor(modelItem => item.Semester_Code)
- @Html.DisplayFor(modelItem => item.Semester_Duration_In_Weeks)
- @Html.DisplayFor(modelItem => item.Status)
- @Html.DisplayFor(modelItem => item.Semester_Start_Date)
- @Html.DisplayFor(modelItem => item.Semester_End_Date)
- @Html.DisplayFor(modelItem => item.Semester_Credit_Hours)
- @Html.DisplayFor(modelItem => item.Date_Created)
- @Html.DisplayFor(modelItem => item.Date_Modified)
- @Html.DisplayFor(modelItem => item.Added_By)
- @Html.ActionLink("Edit", "Edit", new { id=item.Semester_Id }) |
- @Html.ActionLink("Details", "Details", new { id=item.Semester_Id }) |
- @Html.ActionLink("Delete", "Delete", new { id=item.Semester_Id })
- }
Ashutosh GuptaPosted Dec 12, 2019, 3:01 AM
Mark TaborPosted Dec 12, 2019, 3:02 AM
Mark TaborPosted Dec 12, 2019, 2:52 AM
Ashutosh Gupta for continuous help , as i have not column in db which is related to Students so for that do i need to create first a column to the database , and then create a navigation property in the class then i would be able to include that in my controller code
Ashutosh GuptaPosted Dec 12, 2019, 2:35 AM
Mark TaborPosted Dec 11, 2019, 11:10 PM
Mark TaborPosted Dec 11, 2019, 11:08 PM
Ashutosh GuptaPosted Dec 11, 2019, 11:03 PM
Mark TaborPosted Dec 11, 2019, 10:52 PM
Ashutosh Gupta it is simply dbset<> as all other are
Ashutosh GuptaPosted Dec 11, 2019, 9:47 PM