How could i get selected value from dropdownlist in kendo ui grid in mvc

Posted by Karthik Bammidi on Stack Overflow See other posts from Stack Overflow or by Karthik Bammidi
Published on 2012-07-14T13:00:49Z Indexed on 2013/07/02 5:05 UTC
Read the original article Hit count: 1932

Filed under:
|
|

I am working on Kendo UI with asp.net mvc razor. I am trying to bind database table data with kendo grid that supports CRUD operations. Here i need to populate a dropdownlist for one of my table field. I have used the following code

View:

@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))
 )

Here i need to store the selected item from the dropdownlist. But it always shows null. How could i get the selected value from dropdownlist.

© Stack Overflow or respective owner

Related posts about asp.net-mvc-3

Related posts about Razor