title: how to convert formcollection to model in mvc
body: <p>Is it possible to convert <code>formcollection</code> to a 'model' known?</p>
  
  <pre><code>[HttpPost]
      public ActionResult Settings(FormCollection fc)
      {
      var model=(Student)fc; // Error: Can't convert type 'FormCollection' to 'Student'
      }
  </code></pre>
  
  <p>NOTE : for some reasons i can't use ViewModel instead.</p>
  
  <p>Here is my code VIEW: Settings.cshtml</p>
  
  <pre><code>@model MediaLibrarySetting
  @{
  ViewBag.Title = "Library Settings";
  var extensions = (IQueryable&lt;MediaLibrarySetting&gt;)(ViewBag.Data);    
  }
  @helper EntriForm(MediaLibrarySetting cmodel)
  {   
  
  &lt;form action='@Url.Action("Settings", "MediaLibrary")' id='MLS-@cmodel.MediaLibrarySettingID' method='post' style='min-width:170px' class="smart-form"&gt;
      @Html.HiddenFor(model =&gt; cmodel.MediaLibrarySettingID)
      &lt;div class='input'&gt;
          &lt;label&gt;
         New File Extension:@Html.TextBoxFor(model =&gt; cmodel.Extention, new { @class = "form-control style-0" })
          &lt;/label&gt;
          &lt;small&gt;@Html.ValidationMessageFor(model =&gt; cmodel.Extention)&lt;/small&gt;
      &lt;/div&gt;
      &lt;div&gt;
          &lt;label class='checkbox'&gt;
              @Html.CheckBoxFor(model =&gt; cmodel.AllowUpload, new { @class = "style-0" })&lt;i&gt;&lt;/i&gt;&amp;nbsp;
              &lt;span&gt;Allow Upload.&lt;/span&gt;&lt;/label&gt;
      &lt;/div&gt;
      &lt;div class='form-actions'&gt;
          &lt;div class='row'&gt;
              &lt;div class='col col-md-12'&gt;
                  &lt;button class='btn btn-primary btn-sm' type='submit'&gt;SUBMIT&lt;/button&gt;
              &lt;/div&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;/form&gt;
  }
  &lt;tbody&gt;
  @foreach (var item in extensions)
   {
    if (item != null)
     {                                    
      &lt;tr&gt;
       &lt;td&gt;
        &lt;label class="checkbox"&gt;
         &lt;input type="checkbox"  value="@item.MediaLibrarySettingID"/&gt;&lt;i&gt;&lt;/i&gt;
          &lt;/label&gt;
            &lt;/td&gt;
             &lt;td&gt;
               &lt;a href="javascript:void(0);" rel="popover" class="editable-click"
              data-placement="right"
              data-original-title="&lt;i class='fa fa-fw fa-pencil'&gt;&lt;/i&gt; File Extension"
              data-content="@EntriForm(item).ToString().Replace("\"", "'")" 
              data-html="true"&gt;@item.Extention&lt;/a&gt;&lt;/td&gt;
                      &lt;/tr&gt;
                      }
                  }
                  &lt;/tbody&gt;
  </code></pre>
  
  <p>CONTROLLER:</p>
  
  <pre><code>[HttpPost]
  public ActionResult Settings(FormCollection fc)//MediaLibrarySetting cmodel - Works fine for cmodel
  {
          var model =(MediaLibrarySetting)(fc);// Error: Can't convert type 'FormCollection' to 'MediaLibrarySetting'
  }
  </code></pre>
  
  <p><code>data-content</code> and <code>data-</code> attributes are bootstrap popover.</p>