title: Can't programmatically select option using Select2
body: <p>I have a Select2 working fine attached to a select list but when someone enters a new item and I rebind the select list and try to programmatically select the new item, it refuses to display.<br>
  There are a number of other posts re this but their solutions don't work for me.  </p>
  
  <ol>
  <li>Use <code>.select2("val", value)</code>. Does nothing. </li>
  <li>Use <code>.select2("data", value)</code>. Does nothing. Not sure how this is supposed to be different.  </li>
  <li>Use the <code>InitSelection</code> option to set a value. This leads to the following error message: <code>Uncaught Error: Option 'initSelection' is not allowed for Select2 when attached to a select element</code>.</li>
  </ol>
  
  <p>In the Ajax success function after adding the new option to the database, I have the following Javascript:</p>
  
  <pre><code>BindDishes(RestaurantID); //rebinds the select list successfully
  $('#hidDishID').val = data.DishID; //populates a hidden field
  var arr = '[{id: "' + data.DishID + '", text: "' + data.DishName + '"}]'; 
  $("#dd").select2("data", arr);
  </code></pre>
  
  <p>So in this latest iteration I have tried to supply an array with the id and text from the select list item as per another suggested solution but still nothing occurs.  What am I doing wrong?  Is this impossible when using Select2 with a select list?</p>
  
  <p><strong>Edit</strong>: I have the following line in MVC that creates the Select list:</p>
  
  <pre><code>@Html.DropDownGroupListFor(m =&gt; m.DishID, Model.GroupedSelectList, "Select a dish", new { id="dd",style="width:470px;" })
  </code></pre>
  
  <p>which must be causing the problem by binding to DishID from the model which was originally blank when it came from the server.  DropDownGroupListFor is just an HTML helper that allows for using OptionGroups in a Select but it must be the binding that is a problem.  What is the best approach here, to bind in a different way or to somehow update the model's DishID, not sure of the best practice?</p>