title: VB Net CheckboxList Send Mail Based on ListItem Value
body: <p>I am trying to change the variable:</p>
  
  <pre><code>.ToAddress = ConfigurationManager.AppSettings("RequestEmail")
  </code></pre>
  
  <p>based on the selected value in the CheckBoxList ListItem.  So far it's not working.</p>
  
  <p>Here's the code for that list:</p>
  
  <pre><code>&lt;asp:CheckBoxList runat="server" ID="m_chckbxlstProperties" RepeatDirection="horizontal" RepeatColumns="2" CssClass="checkboxlist"&gt;
      &lt;asp:ListItem Value="1"&gt;&lt;/asp:ListItem&gt;
      &lt;asp:ListItem Value="2"&gt;&lt;/asp:ListItem&gt;
      &lt;asp:ListItem Value="3"&gt;&lt;/asp:ListItem&gt;
      &lt;asp:ListItem Value="4"&gt;&lt;/asp:ListItem&gt;
      &lt;asp:ListItem Value="5"&gt;&lt;/asp:ListItem&gt;
      &lt;asp:ListItem Value="6"&gt;&lt;/asp:ListItem&gt;
      &lt;asp:ListItem Value="7"&gt;&lt;/asp:ListItem&gt;
      &lt;asp:ListItem Value="8"&gt;&lt;/asp:ListItem&gt;
      &lt;asp:ListItem Value="9"&gt;&lt;/asp:ListItem&gt;
  &lt;/asp:CheckBoxList&gt; 
  </code></pre>
  
  <p>Here is the code behind:  </p>
  
  <pre><code>For Each li In m_chckbxlstProperties.Items
    If li.Value = "1" Then
     If li.Selected Then
      .ToAddress = ConfigurationManager.AppSettings("1RequestEmail")
     End If
    Else If li.Value = "2" Then
    If li.Selected Then
      .ToAddress = ConfigurationManager.AppSettings("2RequestEmail")
     End If
    Else If li.Value = "3" Then
    If li.Selected Then
       .ToAddress = ConfigurationManager.AppSettings("3RequestEmail")
      End If    
    Else If li.Value = "4" Then
    If li.Selected Then
       .ToAddress = ConfigurationManager.AppSettings("4RequestEmail")
      End If  
    Else
       .ToAddress = ConfigurationManager.AppSettings("RequestEmail")
      End If
    End If
   Next
  </code></pre>