如何使用模型绑定Kendo ui下拉列表以及如何使用按钮Click将所选值发送到控制器 其他业务......
你可以详细解释一下......我是一个新鲜的...... 提前谢谢答案 0 :(得分:0)
查看:强>
@model Contract
@{
var vendors = ViewData["Lookups"] as List<Vendor>;
}
@using (Html.BeginForm("Create", "Contract", FormMethod.Post, new { id = "contractDetailsForm" }))
{
@Html.ValidationSummary(true)
<fieldset>
<legend>Contract</legend>
<div>
@{
Html.Kendo().DropDownListFor(model => model.VendorId).Name("VendorId")
.BindTo(new SelectList(vendors, "ID", "DisplayName", "Nothing Selected"))
.HtmlAttributes(new { @style = "width:250px;" })
.Value(Model.VendorId.ToString())
.Render();
}
</div>
<div>
<button type="submit" class="k-button k-button-icontext">
<span class="k-icon k-insert"></span>Create Contract</button>
</div>
</fieldset>
}
<强>控制器:强>
[HttpPost]
public ActionResult Create(Contract contract)
{
if (ModelState.IsValid)
{
contract.ID = Guid.NewGuid();
_repository.Add(contract);
_repository.SaveChanges();
//return or redirect to another View ...
}
return View("Create", contract);
}
答案 1 :(得分:0)
为下拉列表编写选择事件,如
function onSelect(e) {
var DropDownval = $("#QuestionType").val();
}
将此值放在会话或变量中,并将其传递给控制器。