Seth
Seth

Reputation: 363

Using Kendo UI MVC DropDownListFor, how do i pass the selected text along to the controller during the submit form?

Im using Ajax.BeginForm and I need to pass the selected text to the controller on the submit. Right now it is passing the Value(id) but I need the Text. Any ideas?

@using (Ajax.BeginFrom("Index", "Home", new AjaxOptions { HttpMethod = "Post" }))
{
   <fieldset>
   <ol>
      <li>
         @(Html.Kendo().DropDownListFor(m => m.Office)
            .Name("officeDropDownList")
            .DataValueField("Value")
            .DataTextField("Text")
            .DataSource(source => 
            {
               source.Read(read =>
                 {
                    read.Action("GetOffices", "Home");
                 });
            })
         )
     </li>
  </ol>
  </fieldset>


}

Upvotes: 0

Views: 1491

Answers (1)

id.ot
id.ot

Reputation: 3151

To get the value text of a dropdown:

$("#ddl").data("kendoDropDownList").text();


**Edit**

In order to return this data to the Controller I believe you need to change the .Name of the ddl to match the ViewModel property. So in your case change to .Name("Office").

Upvotes: 1

Related Questions