how to bind Kendo ui dropdownlist with model and how to send that selected value to controller with a button Click for other operations....
could you please explain be in detail...am a fresher... thanks in advance
how to bind Kendo ui dropdownlist with model and how to send that selected value to controller with a button Click for other operations....
could you please explain be in detail...am a fresher... thanks in advance
View:
@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>
}
Controller:
[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);
}
write select event for the dropdown list like
function onSelect(e) {
var DropDownval = $("#QuestionType").val();
}
put this value in the session or in a variable and pass it to the controller.