I did not expect to stumble upon a problem in such a matter and yet. Here is my presentation:

<select name="EdLevel"> <option value="">Высшее - Бакалавр</option> <option value="">Высшее - Магистр</option> <option value="">Кандидат Наук</option> <option value="">Доктор Наук</option> <option value="">Неоконченное высшее</option> <option value="">Среднее Специальное</option> <option value="small_form_wanted">Среднее</option> </select> 

And there is a model with a field:

  public string EdLevel { get; set; } 

Every time you try to send a value from the list, null is sent to the controller. Although if I use normal input instead of a list, like this:

 <input type="text" name="EdLevel"/> 

then no problem. Apparently the difficulty is in the select control. As the data type in the model tried not a string, but a SelectListItem - the result is the same. The question is - how can you still pass the selected value?

  • <option value="" -> <option value="1" - Igor
  • @Igor and everything was simple. thanks no more questions - Sergey

1 answer 1

The value that is passed to the server with the form data for the named select element is taken from the value attribute of the selected option element:

 <select name="EdLevel"> <option value="1">Высшее - Бакалавр</option> <option value="2">Высшее - Магистр</option> <option value="3">Кандидат Наук</option> ...