title: About setting the default value of html.dropdownlist
body: <p>I was making a website that can compare data table
  User can choose the data table by using dropdownlist.</p>
  
  <p>I have set the default value for "InputDataTable2". 
  And after user finish choosing the data table and submit for the result.
  Although it can pass the correct table to the controller,
  but the value of "InputDataTable2" will auto set back to the default value.</p>
  
  <p>I only need to set the default value for "InputDataTable2" when the user  first time go in this page.
  After user chosen a table and submited, The "InputDataTable2" should be stay same as the user chosen table when returning the result.</p>
  
  <p>I have tried set Selected = true and it doesn't work so i tried jQuery now.</p>
  
  <p>Is there any way to stop the jQuery running after the first time running?</p>
  
  <p><strong>View</strong></p>
  
  <pre><code>@using (Html.BeginForm("Compare", "Home", FormMethod.Post))
  {
      @Html.Raw("New :"
      @Html.DropDownList("InputDataTable1", (IEnumerable&lt;SelectListItem&gt;)ViewBag.InputDataTable1)&lt;br/&gt;
      @Html.Raw("Base:")
      @Html.DropDownList("InputDataTable2", (IEnumerable&lt;SelectListItem&gt;)ViewBag.InputDataTable2)&lt;br /&gt;
      &lt;input type="submit" value="compare" /&gt;
  }
  
  &lt;script&gt;
      $(document).ready(function ()
      {
          $('#InputDataTable2')[0].selectedIndex = 1;
      });
  &lt;/script&gt;
  </code></pre>
  
  <p><strong>Controller</strong></p>
  
  <pre><code>public ViewResult CompareReport()
          {
              List&lt;SelectListItem&gt; reportList = new List&lt;SelectListItem&gt;();
              reportList = GetReportList();
              DataTable Tables = DatabaseHelper.GetCategoryReportSnapshotList();
              ViewBag.CMDataTable1 = Tables.Rows[0][0].ToString();
              ViewBag.CMDataTable2 = Tables.Rows[1][0].ToString();
              ViewBag.InputDataTable1 = reportList;
              ViewBag.InputDataTable2 = reportList;
  
              DataSet dsResult = DatabaseHelper.Compare2Snapshot(ViewBag.CMDataTable2, ViewBag.CMDataTable1);
  
              return View("CompareReport", dsResult);
          }
  
          [HttpPost]
          public ActionResult CompareReport(string InputDataTable1, string InputDataTable2)
          {
              List&lt;SelectListItem&gt; reportList = new List&lt;SelectListItem&gt;();
              reportList = GetReportList();
              ViewBag.InputDataTable1 = InputDataTable1;
              ViewBag.InputDataTable2 = InputDataTable2;
              DataSet dsResult = DatabaseHelper.Compare2Snapshot(InputDataTable2, InputDataTable1);
              ViewBag.InputDataTable1 = reportList;
              ViewBag.InputDataTable2 = reportList;
              return View("CompareReport", dsResult);
          }
  </code></pre>