title: How to bind dropdown list in edit page use of for loop in asp.net mvc
body: <p>I was writing different type of code from Google but it is not display correct value in the dropdown. It shows the correct value in the textbox but not selected value in the dropdown.    </p>
  
  <p><strong>Model</strong></p>
  
  <pre><code>public Int64 EvaluationInfoID { get; set; }
  
  public Int64 EvalCategoryID { get; set; }
  
  public string EvalCategoryName { get; set; }
  
  public string EvalCategoryDesc { get; set; }
  
  public Int64 UserID { get; set; }
  
  public DateTime? EvaluationDate { get; set; }
  
  public int EvalTypeID { get; set; } 
  </code></pre>
  
  <p><strong>Controller</strong></p>
  
  <pre><code>var models = new List&lt;EvaluationInfoViewModel&gt;();
  ViewBag.GridState = this.GridRouteValues();
  
  string serachCriteria = string.Format("created_by={0} and to_date(to_char(evaldate,'MM/DD/YYYY'),'MM/DD/YYYY')={1} ", Convert.ToInt32(Session["UserID"]), "to_date('" + evaldate.ToShortDateString() + "','MM/DD/YYYY')");
  
  PODService.EvaluationInfo[] getData = service.GetEvaluationInfoBySearchCriteria(serachCriteria);
  
  PODService.EvaluationCategory[] evalcat = service.GetEvalCategoryBySearchCriteria(" EC.Eval_ID= 1");//150811VP: For Self Evaluation Eval_ID=1
  PODService.EvaluationType[] evalTypes = service.GetEvaluationTypeList();
  ViewData["EVALTYPE"] = new SelectList(evalTypes, "EvaluationType_ID", "EvaluationType_Name");
  
  
  
  for (var i = 0; i &lt; getData.Length; i++)
  {
      models.Add(new EvaluationInfoViewModel());
  }
  
  for (var i = 0; i &lt; models.Count; i++)
  {
      string serachCriteria1 = string.Format("created_by={0} and to_date(to_char(evaldate,'MM/DD/YYYY'),'MM/DD/YYYY')={1} ", Convert.ToInt32(Session["UserID"]), "to_date('" + evaldate.ToShortDateString() + "','MM/DD/YYYY')");
      models[i].EvalCategoryID = getData[i].EvalCategory_ID;
      models[i].EvalCategoryName = getData[i].EvalCategoryName;
      //models[i].EvalCategoryDesc = getData[i].Eval_CategoryDescription;
      models[i].UserID = Convert.ToInt64(Session["UserID"]);
  
      models[i].EvaluationDate = getData[i].EvaluationDate;
      models[i].EvalTypeID = getData[i].EvalTypeID;
  
      ViewData["EVALTYPEInfo"] = new SelectList(evalTypes, "EvaluationType_ID", "EvaluationType_Name", models[i].EvalTypeID);
  </code></pre>
  
  <p><strong>View</strong></p>
  
  <pre><code>@model  List&lt;PODWeb.Models.EvaluationInfoViewModel&gt;
  @{
      Layout = null;
  
  }
  @using (Html.BeginForm("EditEvaluationInfo", "EvaluationInfo", FormMethod.Post))
  {  
      &lt;table border="1px" style="margin-left: 122px"&gt;
          &lt;tr&gt;
              &lt;td&gt;
                  &lt;table&gt;
                      @for (var i = 0; i &lt; Model.Count(); i++)
                      {
                          @Html.HiddenFor(m=&gt;m[i].UserID)
                          @Html.HiddenFor(m=&gt;m[i].EvaluationDate)
                          @Html.HiddenFor(m =&gt;m[i].EvalTypeID)
                          &lt;tr&gt;
                              &lt;td&gt;
                                  @Model[i].EvalCategoryName
                              @Html.EditorFor(m =&gt;m[i].EvalTypeID)
                              &lt;/td&gt;
                              &lt;td&gt;
  
                                @*@Html.DropDownListFor(m =&gt; m[i].EvalTypeID, ViewData["EVALTYPEInfo"] as IEnumerable&lt;SelectListItem&gt;, "Select Rating", new { @style = "width:200px" })*@
  
  
                              &lt;/td&gt;
                          &lt;/tr&gt;
  
                          &lt;tr&gt;
                              &lt;td&gt;
                                  @Model[i].EvalCategoryDesc
                                  @Html.HiddenFor(m =&gt; m[i].EvalCategoryID)
                              &lt;/td&gt;
                              &lt;td&gt;
  
                              &lt;/td&gt;
                          &lt;/tr&gt;
                          &lt;tr&gt;
                              &lt;td colspan="2"&gt;
                                  &lt;hr /&gt;
                              &lt;/td&gt;
                          &lt;/tr&gt;
  
  
                      }
                      &lt;tr&gt;
                          &lt;td&gt;
                              &lt;input type="submit" name="Save" value="Save" class="t-button" style="margin-left: 471px" /&gt;
                          &lt;/td&gt;
                      &lt;/tr&gt;
                  &lt;/table&gt;
              &lt;/td&gt;
          &lt;/tr&gt;
  
      &lt;/table&gt;
  }
  </code></pre>
  
  <p>I want to display selected evaltypeid in dropdownlist but it is not displaying.</p>