این مدل شماست ؟
لطفا کد کامل ویو و مدل را قرار دهید
[Key] public int PersonId { get; set; } public int Userid { get; set; } [Display(Name = "نام مسیر")] [Required(ErrorMessage = "لطفا {0}را وارد نمایید")] public int RoutId { get; set; } [Display(Name = "نام ایستگاه")] [Required(ErrorMessage = "لطفا {0}را وارد نمایید")] public int StationId { get; set; } [Display(Name = "تاریخ ویرایش")] public DateTime DateInput { get; set; } [Display(Name = "تاریخ ویرایش")] public DateTime DateEdit { get; set; } //foreignkey Rout_service in tableTeacher_Service [ForeignKey("RoutId")] public virtual Rout_Service RoutService { get; set; } //foreignkey Rout_service in tableTeacher_Service [ForeignKey("StationId")] public virtual Station_service StationService { get; set; } //foreignkey User in table Rout_service [ForeignKey("Userid")] public virtual Users user { get; set; } public Teacher_Service() { }
<hr /> @Html.ValidationSummary(true, "", new { @class = "text-danger" }) @*<div class="form-group"> @Html.LabelFor(model => model.Userid, "Userid", htmlAttributes: new { @class = "control-label col-md-2" }) <div class="col-md-10"> @Html.DropDownList("Userid", null, htmlAttributes: new { @class = "form-control" }) @Html.ValidationMessageFor(model => model.Userid, "", new { @class = "text-danger" }) </div> </div>*@ <div class="form-group"> @Html.LabelFor(model => model.RoutId, "RoutId", htmlAttributes: new { @class = "control-label col-md-2" }) <div class="col-md-10"> @Html.DropDownList("RoutId", null, "-- انتخاب ---", htmlAttributes: new { @class = "form-control" }) @Html.ValidationMessageFor(model => model.RoutId, "", new { @class = "text-danger" }) </div> </div> <div class="form-group"> @Html.LabelFor(model => model.StationId, "StationId", htmlAttributes: new { @class = "control-label col-md-2" }) <div class="col-md-10"> @Html.DropDownList("StationId", null, "-- انتخاب ---", htmlAttributes: new { @class = "form-control" }) @Html.ValidationMessageFor(model => model.StationId, "", new { @class = "text-danger" }) </div> </div> <div class="form-group"> @Html.LabelFor(model => model.DateInput, htmlAttributes: new { @class = "control-label col-md-2" }) <div class="col-md-10"> @Html.EditorFor(model => model.DateInput, new { htmlAttributes = new { @class = "form-control" } }) @Html.ValidationMessageFor(model => model.DateInput, "", new { @class = "text-danger" }) </div> </div> <div class="form-group"> @Html.LabelFor(model => model.DateEdit, htmlAttributes: new { @class = "control-label col-md-2" }) <div class="col-md-10"> @Html.EditorFor(model => model.DateEdit, new { htmlAttributes = new { @class = "form-control" } }) @Html.ValidationMessageFor(model => model.DateEdit, "", new { @class = "text-danger" }) </div> </div>
عرض کردم کد کامل نه بخشی از کد
-------------------------------------------------------------------------------
@model DataLayer.Teacher_Service
<h2>Create</h2>
به شکل زیر اصلاح کنید
@using (Html.BeginForm()) { @Html.AntiForgeryToken() <div class="form-horizontal"> <h4>Teacher_Service</h4> <hr /> @Html.ValidationSummary(true, "", new { @class = "text-danger" }) <div class="form-group"> @Html.LabelFor(model => model.Userid, htmlAttributes: new { @class = "control-label col-md-2" }) <div class="col-md-10"> @Html.DropDownList("Userid", null, htmlAttributes: new { @class = "form-control" }) @Html.ValidationMessageFor(model => model.Userid, "", new { @class = "text-danger" }) </div> </div> <div class="form-group"> @Html.LabelFor(model => model.RoutId, htmlAttributes: new { @class = "control-label col-md-2" }) <div class="col-md-10"> @Html.DropDownList("RoutId", null, "-- انتخاب ---", htmlAttributes: new { @class = "form-control" }) @Html.ValidationMessageFor(model => model.RoutId, "", new { @class = "text-danger" }) </div> </div> <div class="form-group"> @Html.LabelFor(model => model.StationId, "StationId", htmlAttributes: new { @class = "control-label col-md-2" }) <div class="col-md-10"> @Html.DropDownList("StationId", null, "-- انتخاب ---", htmlAttributes: new { @class = "form-control" }) @Html.ValidationMessageFor(model => model.StationId, "", new { @class = "text-danger" }) </div> </div> <div class="form-group"> @Html.LabelFor(model => model.DateInput, htmlAttributes: new { @class = "control-label col-md-2" }) <div class="col-md-10"> @Html.EditorFor(model => model.DateInput, new { htmlAttributes = new { @class = "form-control" } }) @Html.ValidationMessageFor(model => model.DateInput, "", new { @class = "text-danger" }) </div> </div> <div class="form-group"> @Html.LabelFor(model => model.DateEdit, htmlAttributes: new { @class = "control-label col-md-2" }) <div class="col-md-10"> @Html.EditorFor(model => model.DateEdit, new { htmlAttributes = new { @class = "form-control" } }) @Html.ValidationMessageFor(model => model.DateEdit, "", new { @class = "text-danger" }) </div> </div> <div class="form-group"> <div class="col-md-offset-2 col-md-10"> <input type="ثبت اطلاعات" value="Create" class="btn btn-default" /> </div> </div>
هیچ کاربری تا کنون از این پست تشکر نکرده است
با ما تماس بگیرید تا در این مسیر همراهتان باشیم :)