title: Add a dynamic dropdown field to Razor view
body: <p>I am building a form based on the model with this structure</p>
  
  <pre><code>public class DynamicFormElementsModel
  {
      //param might be shown in UI , but will not pass while setting params for report . Example select org.  
      public bool ReportParameter { get; set; }
  
      public string  ParamName { get; set; }
  
      public string ParamLabel { get; set; }
  
      public string ParamType { get; set; }
  
      public bool Visible { get; set; }
  
      public string ParamValue { get; set;}
  }
  </code></pre>
  
  <p>And in Razor i am building the control like </p>
  
  <pre><code> @using (Html.BeginForm("Index", "Reports", FormMethod.Post, new { role = "form" }))
          {
              @Html.HiddenFor(p =&gt; Model.ReportId)
              for (int i = 0; i &lt; Model.Parameters.Count(); i++)
              {
                  &lt;div class="form-group"&gt;
                      &lt;label class="control-label"&gt;@Model.Parameters[i].ParamLabel&lt;/label&gt;
  
                      @switch (@Model.Parameters[i].ParamType.ToLower())
                      {
                          case "textbox":
                              if (@Model.Parameters[i].Visible)
                              {
                                  &lt;input type="text" class="form-control" value="@Model.Parameters[i].ParamValue" name="@Model.Parameters[i].ParamName" /&gt;
                              }
                              else
                              {
                                  &lt;input type="hidden" value="@Model.Parameters[i].ParamValue" name="@Model.Parameters[i].ParamName" /&gt;
                              }
                              break;
                          default:
                              break;
                      }
                  &lt;/div&gt;
              }
                  &lt;input type="submit" class="btn btn-default" value="Submit" /&gt;
          }
  </code></pre>
  
  <p>Normal textboxes will be rendered correctly with this approach . But how can i make a dropdown and  fill the dropdown  from a table id , name value pair from the sql table </p>