---
title: "Post form get null values in Model"  
description: "Post form get null values in Model"  
author: "Takeshi Okada"  
published: 2014-03-29  
updated: 2014-03-29  
canonical: https://www.mindstick.com/forum/2001/post-form-get-null-values-in-model  
category: "asp.net mvc"  
tags: ["asp.net mvc"]  
reading_time: 2 minutes  

---

# Post form get null values in Model

When I submit a [form](https://www.mindstick.com/forum/6/multi-form-mfc-application), my [Courses](https://www.mindstick.com/articles/12720/searching-for-the-best-courses-in-mba-read-on) List into my [ViewModel](https://www.mindstick.com/forum/157215/what-is-viewmodel-in-mvc) is getting [null values](https://www.mindstick.com/interview/34072/optional-class-in-java-handling-null-values-more-effectively). This is my ViewModel:

```
public class CandidateViewModel{    public string Name { get; set; }    public IList<CourseViewModel> Courses { get; set; }    public CandidateViewModel()    {        Name ="Kiwanax";        Courses = new List<CourseViewModel>();        for (int count = 0; count < 5; ++count)        {           
Courses.Add(new CourseViewModel(                
string.Format("Course_{0}", count), 5));        }    } }public class CourseViewModel{    public long ID {get; set; }    public string Name{ get; set; }    public OptionViewModel SelectedOption { get; set; }    public IList<OptionViewModel> Options { get; set; }    public CourseViewModel(string name, int numberOfOptions)     {        Name = name;        Options = new List<OptionViewModel>();        for (int count = 1; count <= numberOfOptions; ++count)        {           
Options.Add(new OptionViewModel(count.ToString(),                
string.Format("Option {0}", count)));        }        SelectedOption = Options[0];    }}public class OptionViewModel{    public string Value { get; set; }    public string Description { get; set; }}
```

```
OK. When I create DropDownLists based on my IList, it works fine.<ul id="cursos">@for (int count = 0; count < Model.Courses.Count; ++count){    <li>       
@Html.DropDownListFor(i => i.Courses[count].SelectedOption,            new
SelectList(Model.Courses[count].Options, "Value", "Description", Model.Courses[count].SelectedOption))               
@Html.HiddenFor(i => i.Courses[count].ID)      @Model.Courses[count].Name           
</li>        }        </ul>
```

But, when I do [post](https://www.mindstick.com/articles/12829/aspects-that-make-australia-post-shipping-extension-a-useful-tool) from my form, I'm getting null values from that IList.

## Replies

### Reply by Pravesh Singh

Hi Takeshi,

You cannot bind dropdowns to complex property [values](https://www.mindstick.com/forum/327/sum-textbox-values):

i => i.Courses[count].SelectedOption

It must be bound to the corresponding primitive type that will be sent to the server:

i => i.Courses[count].SelectedOption.Value

Remember that in HTML the <select> element only sends the selected value as a simple string type to the server.


---

Original Source: https://www.mindstick.com/forum/2001/post-form-get-null-values-in-model

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
