ASP.NET MVC 2 Drop Down List In Place of Master List Grid
Instead of a grid with an 'Edit' link in each row, I'd like to use a drop down list and a single 'Edit' button. What's the cleanest way to make that button direct to /Edit/{id}(i.e. the ddl selected value)? Using onclick with window.开发者_如何学Clocation is way too ugly, super ugly if I have to account for the url base being http://approot/ or http://approot/controllername/ since it's on the Index view.
You can use any kind of form presentation, you just have to make sure the name of the value you're submitting matches the type and name what the controller is expecting.
For example on the page:
<select id="userList" name="userList">
<option value=1>My Name</option>
<option value=2>Your Name</option>
</select>
and then the controller that the form is talking to should look something like:
public ActionResult Edit(int userList){......
then whatever option was selected will pass its value to the controller, as long as the names match and the form's action is the correct controller action
You can always use simple html form with dropdown and submit button.
精彩评论