title: asp:DropDownList selectedvalues in multiple selection list
body: <p>I have asp:DropDownList wich is populated from SQLdatasource and I need to set selected items on select list (asp:DropDownList or asp:DropDownList). </p>
  
  <p>Here is my code:</p>
  
  <pre><code>      &lt;asp:SqlDataSource runat="server" ID="sqlAihealueet"
   ConnectionString="Server=SQL2008;Database=Data;UID=123;PWD=123"
    SelectCommand="SELECT        TOP (100) PERCENT valikkoaktiivinen, alue, id, otsikko, osa1b, osa2b, osa3b, osa4b FROM            dbo.FiValikko"&gt;&lt;/asp:SqlDataSource&gt;
  
    &lt;asp:DropDownList  name="aihevalinta" id="aihevalinta"  multiple="true" DataSourceid="sqlAihealueet" DataValueField="id" DataTextField="otsikko"  class="populate placeholder"  style="width:450px; font-size:11px" runat="server"&gt;
              &lt;/asp:DropDownList&gt; 
  </code></pre>
  
  <p>On this page I have all other fields set up on codebehind like this:</p>
  
  <pre><code>vapaaselite.text = drRow.Item("vapaaselitetxt").ToString
  </code></pre>
  
  <p>How should I make that multiple selected ones to that select list on?  </p>
  
  <p>I have tryed this (aihealueet data = "9682,9683"):</p>
  
  <pre><code>aihevalinta.SelectedValues = drRow.Item("aihealueet")
  </code></pre>
  
  <p>not working, gives me error: SelectedValues' is not a member of 'System.Web.UI.WebControls.DropDownList</p>
  
  <p>Is there way I could make selecteced items straight from  sql datasource, from SQLquery? I could mark them easily on SQLquery.</p>
  
  <p>...or how Do I do this with asp:Listbox? I tryed same kind of aproach. I only can get one item as selected. If I try to make other one selected too the first selected ones select state disappears.</p>
  
  <pre><code>aihevalinta.SelectedValue = "9565"
  aihevalinta.SelectedValue = "9566"
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/O1kkE.jpg" alt="enter image description here"></p>
  
  <p>The best solution for me would be to mark selected one straigt from SQldatasource (same where the list comes form). data would be like this:</p>
  
  <p><img src="https://i.stack.imgur.com/gHoqx.jpg" alt="enter image description here"></p>