This is a migrated thread and some comments may be shown as answers.

Posting selected data-item to controller

1 Answer 60 Views
DropDownList
This is a migrated thread and some comments may be shown as answers.
Hope
Top achievements
Rank 1
Hope asked on 18 Mar 2020, 08:18 PM

Hello All,

I wish to seek your guidance on this question.  How do we post strong type to the controller? More specifically, can we post the selected data-item to the controller?

Here is the sample form:

<form asp-controller="home" asp-action="UpdateMenu" method="post">
    <!-- Input and Submit elements -->
    @(Html.Kendo().DropDownList()
          .Name("selectedOptions")
          .DataTextField("Name")
          .DataValueField("ID")
          .DataSource(source => {
              source.Read(read => {
                  read.Action("OptionList", "home");
              });
          })         
    )
     <button type="submit">Update</button>
</form>

 

Here is the controller:

[HttpPost]
public void UpdateMenu(Menu targetMenu, string[] selectedOptions)
{
    ....
}

 

I am able to get the selected ID to bind to the selectedOptions variable but no luck with the data-item object. 

Thank you for your time. 

1 Answer, 1 is accepted

Sort by
0
Ivan Danchev
Telerik team
answered on 23 Mar 2020, 04:20 PM

Hello Hope,

The DropDownList sends only its value, in this case the selected item's ID value. There is an existing feature request in our Feedback Portal for making possible the submission of the data item, which you can vote for.

Veselin's comment in the linked feature request item, contains more details on why this currently is not possible.

Regards,
Ivan Danchev
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
Tags
DropDownList
Asked by
Hope
Top achievements
Rank 1
Answers by
Ivan Danchev
Telerik team
Share this question
or