I have a portion of a table whose values depend on the value in my dropdownlist. How can I update the the table when the selected option of the dropdownlist changes.
grid
@foreach (var choice in ViewData.Model.Options where choiceId == ViewData.Model.choiceLevelId)
{
<tr class='gridrow'>
<td>.....
dropdown
<div class="editor-field">
@Html.DropDownListFor(model => model.choiceLevelId,
(
...
What table are you talking about? ASP.NET MVC has no knowledge of tables or chairs. It works with Models, Controllers and Views.
So you have a View in which you have rendered a
<select>
box and you want upon changing the value of this select box by the user to invoke a Controller Action passing the newly selected value to the server so that it can perform some processing. Am I right?You will have to use javascript in your View in order to subscribe to the change event of this dropdown. Then you have a couple of possibilities:
window.location.href
) to the controller action passing it the selected value as action argument.Depending on your requirements you could pick the technique that suites best for you.
Let me illustrate the first approach with an example using jQuery:
and your controller action that will handle the AJAX request:
UPDATE:
If you wanted to submit the form containing the dropdowns when the selection changes you could use the following: