title: Passing complex data with RadioButton to Controller in MVC5
body: <p>I can't pass complex class from Radio Button to Controller. Is it possible, how I am doing it ?
  I just want to send a object using radio button. The problem is, I receive error null reference.</p>
  
  <pre><code>public class Model1
  {
      public int ID { get; set; }
      public string Name { get; set; }
      public List&lt;ComplexClass&gt; example { get; set; }
      public List&lt;string&gt; SimpleCollection { get; set; }
  }
  
  public class ComplexClass
  {
      public int numerek { get; set; }
      public string slowo { get; set; }
  }
  </code></pre>
  
  <p>Here is a view</p>
  
  <pre><code>@using (Html.BeginForm("GetInfosFromView", "Home", FormMethod.Post)){
  
  //@helper(Model)
  @Complex(Model)
  
  &lt;input type="submit" value="Submit" /&gt;}
  
  
  @helper helper(WebApplication1.Models.Model1 modelx){
  &lt;ul&gt;
      @foreach (var item in modelx.SimpleCollection)
      {
          &lt;li&gt;@item @Html.RadioButtonFor(m =&gt; m.SimpleCollection[0], item)&lt;/li&gt;
      }
  &lt;/ul&gt;}
  
  
  @helper Complex(WebApplication1.Models.Model1 collection){
  &lt;ul&gt;
      @foreach (var item in collection.example)
      {
          &lt;li&gt; @item.Word || @item.Number @Html.RadioButtonFor(m =&gt; m.example[0], item)&lt;/li&gt;
      }
  &lt;/ul&gt;}
  </code></pre>
  
  <p>namespace WebApplication1.Controllers{
      public class HomeController : Controller
      {</p>
  
  <pre><code>    public ActionResult Index()
      {
          return View();
      }
  
      public ActionResult Form()
      {
          Model1 model1 = new Model1();
          model1.SimpleCollection = new List&lt;string&gt;(){"raz", "dwa", "trzy"};
          model1.example = new List&lt;ComplexClass&gt;() {new ComplexClass(){ Number=500, Word="piecset"},
                                                      new ComplexClass(){ Number=1000, Word="tysiąc"},
                                                      new ComplexClass(){ Number=100, Word="sto"}
          };
  
          return View("Form", model1);
      }
  
      //[HttpPost]
      //public ActionResult GetInfosFromView(Model1 model2)
      //{
  
      //    var model = "";
      //    model = model2.SimpleCollection[0];
  
      //    ViewBag.Info = model;
  
      //    return View("Index");
      //}
  
      [HttpPost]
      public ActionResult GetInfosFromView(Model1 model2)
      {
  
          var model = "";
          model = model2.example[0].Number.ToString();
  
          ViewBag.Info = model;
  
          return View("Index");
      }
  }
  </code></pre>
  
  <p>}</p>