3
我正在使用asp.net mvc剃刀处理Kendo UI。我试图用支持CRUD操作的kendo网格绑定数据库表数据。在这里,我需要填充我的表格字段之一的下拉列表。我用下面的代码我怎样才能得到从下拉列表中选择的值在kendo ui网格中的mvc
查看:
@model IEnumerable<MvcApplication1.PriceOption>
@(Html.Kendo().Grid(Model)
.Name("Grid")
.Columns(columns =>
{
//columns.Bound(p => p.ProductTitle).ClientTemplate("<input type='checkbox' disabled='disabled'name='Discontinued' <#= Discontinued? checked='checked' : '' #> />");
columns.Bound(p => p.ProductTitle).EditorTemplateName("OptionalEmail");
columns.Bound(p => p.OptionTitle);
columns.Bound(p => p.Price);
columns.Bound(p => p.Frequency);
columns.Command(command => { command.Edit(); command.Destroy(); }).Width(200);
})
.ToolBar(toolbar => toolbar.Create())
.Editable(editable => editable.Mode(Kendo.Mvc.UI.GridEditMode.InLine))
.Pageable()
.Sortable()
.Scrollable()
.DataSource(dataSource => dataSource
.Ajax()
.Events(events => events.Error("error_handler"))
.Model(model => model.Id(p => p.ProductID))
.Create(create => create.Action("CreateOption", "ZiceAdmin"))
.Read(read => read.Action("Read", "ZiceAdmin"))
.Update(update => update.Action("UpdateOption", "ZiceAdmin"))
.Destroy(update => update.Action("DeleteOption", "ZiceAdmin"))
)
)
OptionalEmail.cshtml
@model string
@(Html.Kendo().DropDownList()
.Name("ProductTitle")
.Value(Model)
.SelectedIndex(0)
.BindTo(new SelectList(ViewBag.ProductTitle))
)
在这里,我需要选择的项目从下拉列表存储。但它总是显示为空。我怎么能从dropdownlist中获得选定的值。
名称值必须不为空..描述:在当前Web请求的执行过程中'出现未处理的异常。请查看堆栈跟踪以获取有关该错误的更多信息以及它在代码中的起源。 异常详细信息:System.ArgumentNullException:值不能为空。 – 2013-08-20 16:35:14