我有一个带有提交按钮的视图。它具有多个控件,其中很多是DropDownLists。在“我的模型”类中,我仅具有某些必需的属性。除非选择了我所有的下拉列表,否则我的页面不会提交,这是我不希望使用它们时需要的额外控件。知道为什么会这样吗?这是我的代码。 (这让我有了软件类型,来源和制造商)
//Model
[Required]
[Display(Name = "Part Book / Category")]
public string PartBook { get; set; }
//decimal
public string PartNextNumber { get; set; }
[Display(Name = "Today's Date")]
public DateTime DateEntered { get; set; }
[Required]
[Display(Name = "Entered By")]
public int EnteredBy { get; set; }
[Display(Name = "Software Type")]
public int SoftwareType { get; set; }
//unsure of this one ********************
[Display(Name = "Assembly Number")]
public string UsedOnAssembly { get; set; }
// INT OR BOOL ?
[Display(Name = "Global Part")]
public bool GlobalPart { get; set; }
//[Required]
public int Source { get; set; }
public int Manufacturer { get; set; }
[Display(Name = "Manufacturer Part Number")]
public string ManufacturerPartNumber { get; set; }
//View
t-danger" })
<div class="panel-body">
<div class="col-md-6 col-lg-6">
@* Change to DropDownList of ParkBooks *@
@*@onchange="location.href='"+
Url.Action("DoPartBookFunc","Parts", "parkbookDDL")+"'" *@
@Html.DropDownListFor(x => x.PartBook,
(IEnumerable<SelectListItem>) ViewBag.PartBookDDL,
"", new { @class = "form-control" })
@Html.ValidationMessageFor(x => x.PartBook,
"", new { @class = "text-danger" })
</div>
<div class="form-group row">
<div class="col-md-3 col-lg-3">
@Html.LabelFor(x => x.SoftwareType,
htmlAttributes: new { @class = "control-label" })
</div>
<div class="col-md-6 col-lg-6">
@Html.DropDownListFor(x => x.SoftwareType,
(IEnumerable<SelectListItem>)ViewBag.SoftwareTypeDDL,
"", new { @class = "form-control" })
@Html.ValidationMessageFor(x => x.SoftwareType, "",
new { @class = "text-danger" })
</div>
<div class="form-group row">
<div class="col-md-3 col-lg-3">
@Html.LabelFor(x => x.Source,
htmlAttributes: new { @class = "control-label" })
</div>
<div class="col-md-9 col-lg-9">
@Html.DropDownListFor(x => x.Source,
(IEnumerable<SelectListItem>) ViewBag.SourceDDL,
"", new { @class="form-control" })
@Html.ValidationMessageFor(x => x.Source,
"", new { @class = "text-danger" })
</div>
</div>
<div class="form-group row">
<div class="col-md-3 col-lg-3">
@Html.LabelFor(x => x.Manufacturer,
htmlAttributes: new { @class = "control-label" })
</div>
<div class="col-md-6 col-lg-6">
@Html.DropDownListFor(x => x.Manufacturer,
(IEnumerable<SelectListItem>)ViewBag.ManufacturerDDL,
"", new { @class="form-control" })
@Html.ValidationMessageFor(x => x.Manufacturer,
"", new { @class = "text-danger" })