ASP.net mvc 4 how to use a dropdown menu?
I'm new to ASP.net MVC 4 (coming from webforms) and so I am a bit confused
on how to do a certain type of functionality.
I created a dropdown box by using
<select>
@for(var item in ViewBag.Items)
{
<option value="@item.ID">@item.name</option>
}
</select>
and let's say I create an "add" button.
<input type="submit" value="Add" />
and I have a table, let's call the table "cars," with a column called
"CarID."
What I want to happen is to hit the add button, a new row gets added to
the cars table with the car ID the user selected in the dropdown box.
How can I make this happen?
No comments:
Post a Comment