//控制器
/// <summary>
/// 下拉框
/// </summary>
/// <returns></returns>
public ActionResult GetSelectType()
{
List<GoodsType> list = tbll.GetSelectType();
return Json(list,JsonRequestBehavior.AllowGet);
}
//视图
<select id="select1" name="TypeId" class="form-control">
<option>-请选择-</option>
</select>
$(function () {
load();
})
function load() {
$.ajax({
url: "https://localhost:44386/GoodsInfo/GetSelectType",
type: "Get",
success: function (data) {
$(data).each(function () {
$("#select1").append('<option value=" ' + this.ID + '">' + this.TypeName + '</option>')
})
}
})
}