@model I.Net4._0.Areas.OMCS.Models.PackMaterialViewModel
<link href="~/EasyUI/themes/default/easyui.css" rel="stylesheet" />
<link href="~/EasyUI/themes/icon.css" rel="stylesheet" />
<script src="~/EasyUI/jquery-1.12.0.js"></script>
<script src="~/EasyUI/jquery.easyui.min.js"></script>
<script src="~/EasyUI/locale/easyui-lang-zh_CN.js"></script>
<table>
<tr><td>@Html.LabelFor(model => model.Line):</td>//对应的就是model中的Display
<td>
@Html.DropDownListFor(model => model.Line, (IEnumerable<SelectListItem>)ViewData["LineSSF"], new { @ID = "selLine", @style = "width:100px" })//后台传输一个viewData["LineSSF"]给前台接收
</td> </tr>
</table>
//题外话: @Html.DropDownListFor语句也可以改写为@Html.DropDownListFor(“LineSSF”,null,new { @ID = "selLine", @style = "width:100px" })
View接收的是一个model,那这个model编辑如下:
public class PackMaterialViewModel
{
[Required(ErrorMessage = "必填")]
[StringLength(20, MinimumLength = 4, ErrorMessage = "{2}到{1}个字符")]
[Display(Name = "序列號")]
public string SN { get; set; }
[Display(Name = "线别")]
public string Line { get; set; }
}