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

Embarrassingly simple question

1 Answer 79 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Jon
Top achievements
Rank 1
Jon asked on 11 Mar 2011, 10:26 PM
Excuse my newby mvc ignorance, please, but I have a form that uses the combo box. I post to the controller and return to the view for the user to enter another record. The view now shows the previous combo box selection, and I'd rather it just showed the, default first value in the dropdown I guess is the best way to put it, because on the initial view no default value is actually set by me. How do I do this?

As an aside, I had the same problem with the Html.TextBox function showing the previous entry, but cleared those values from the model in the controller by using ModelState.Remove("controlname"). Is that the best way to do that? I tried to do that with the combobox but it didn't work.

This seems like an obviously easy thing to do, but I'm stumped, probably due to my inexperience in this environment. Help?

1 Answer, 1 is accepted

Sort by
0
Matthew
Top achievements
Rank 1
answered on 08 Jul 2011, 07:23 AM
I usually RedirectToAction from a HttpPost Action to the Get Action that loaded the Create page.  If you do that then all the fields will be "default" from what the initial Create Get page sets.
Tags
ComboBox
Asked by
Jon
Top achievements
Rank 1
Answers by
Matthew
Top achievements
Rank 1
Share this question
or