title: Select dynamically in Bootstrap-select with multiple values not working
body: <p>I have tried an example:
  <a href="https://stackoverflow.com/questions/32388954/how-to-select-dynamically-in-bootstrap-select-with-multiple-values">this example</a></p>
  
  <p>and its working fine but when I tried to bind dynamically it's not working. Please anyone can help in this.</p>
  
  <p>please find below code:</p>
  
  <p><strong>Dropdown code:</strong></p>
  
  <pre><code> &lt;div class="col-md-4"&gt;
   &lt;div class="form-group"&gt;
   &lt;label for="field-2" class="control-label"&gt;Dropdown&lt;/label&gt;
   &lt;select class="form-control selectpicker" multiple data-selected-text-format="count" data-live-search="true" data-style="btn-white" id="lstdrpdwn" name="lstdrpdwn"&gt;
   &lt;/select&gt;
   &lt;/div&gt;
   &lt;/div&gt;
  </code></pre>
  
  <p>** Jquery:**</p>
  
  <pre><code> function FillDetail(id) {
          $.ajax({
              dataType: "json",
              type: "POST",
              url: '../Getdata',
              data: 'id=' + id,
              async: true,
              success: function (data) {
                  $.each(data, function (i, item) {
                      alert('[' + item.CooperativeUserID + ']');
                      $('#lstdrpdwn').selectpicker('val', '[' + item.CooperativeUserID + ']');  //.val(item.CooperativeUserID);
                      $('#lstdrpdwn').selectpicker('refresh');
                  })
              },
              error: function (jqXHR, textStatus, errorThrown) {
              }
          });
      }
  </code></pre>
  
  <p>Also i have tried to remove <code>//$('#lstdrpdwn').selectpicker('refresh');</code> the lines.</p>
  
  <p>And aslo tried to refresh the selectpicker<br>
   <code>$('.selectpicker').selectpicker('refresh');</code> its not working.</p>
  
  <p>When I bind the values with static IDs it worked fine at the time of filling dropdown.</p>
  
  <pre><code>function filldropdown() {
          return $.ajax({
              dataType: "json",
              type: "POST",
              url: '../Getdropdown',
              data: 'id=0',
              async: true,
              success: function (data) {
                  $("#lstdrpdwn").html("");
                  $.each(data, function (key, val) {
                      $("#lstdrpdwn").append($("&lt;option&gt;&lt;/option&gt;").val(val.ID).html(val.Name));
                  });
                  $('#lstdrpdwn').selectpicker('refresh');
                  $('#lstdrpdwn').selectpicker('val', [2,5]);
  
              },
              error: function (jqXHR, textStatus, errorThrown) {
              }
          });
      }
  </code></pre>