title: Set selected items in a Multiselect asp Listbox (which uses jQuery plugin-Chosen )
body: <p>I have a ListBox on which I have applied a Chosen Jquery plugin. So on Page load I go to DB and bind the items. This works fine with all its autocomplete feature etc. Then I update these values to Database.</p>
  
  <p>When I reaload this item , I want to take the previously saved value and make it the selected Item. </p>
  
  <p>I can get ListItems for which I need to set the Selected Proprty to true . But when I try the code below nothing happens. The Box is empty and no item is selected. How I can so this. Is there a way to kick this off from C# code behind ?</p>
  
  <pre><code>    foreach (ListItem li in mySelectedListItemCollection)
      {
          if (li.Selected)
          {
              ddlMultiSelect.Items.FindByValue(li.Value).Selected = true 
          }
      }
  </code></pre>
  
  <p>my Control looks like</p>
  
  <pre><code>&lt;%@ Control Language="C#" CodeBehind="Edit.ascx.cs" blah blah %&gt;   
   &lt;asp:ListBox ID="ddlMultiSelect" SelectionMode="Multiple" data-placeholder="Choose…" class="chosen-select"  multiple Style="width: 350px;" runat="server"&gt;
  
      &lt;/asp:ListBox&gt;
  
  
      &lt;form&gt;
          &lt;script type="text/javascript"&gt;
      var config = {
      '.chosen-select': {},
      '.chosen-select-deselect': { allow_single_deselect: true },
      '.chosen-select-no-single': { disable_search_threshold: 10 },
      '.chosen-select-no-results': { no_results_text: 'Oops, nothing found!' },
      '.chosen-select-width': { width: "95%" }
      }
      for (var selector in config) {
          $(selector).chosen(config[selector]);
      }
      &lt;/script&gt;
      &lt;/form&gt;
  
      &lt;header&gt;
          &lt;script type="text/javascript"&gt;
          $(document).ready(function () {
              $("#&lt;%=ddlMultiSelect.ClientID %&gt;").change(function () {
                  var arr = $(this).val();
                  if (typeof arr === 'object' &amp;&amp; arr instanceof Array) {
                      document.getElementById('&lt;%=lbltest.ClientID%&gt;').value = arr.toString();
                  }
                  else { document.getElementById('&lt;%=lbltest.ClientID%&gt;').value = ""; }
          console.log(arr)})
      });
      &lt;/script&gt;
      &lt;/header&gt;
  </code></pre>
  
  <p>Essentially at a DataBound event I want to reset the selected items which are saved in DB.
  PS: I am using Chosen 1.3 , ASP.NET 4.0 </p>
  
  <p>Thanks in advance </p>