I am creating a form with multiple CheckBoxLists (8 total) like this:
Configurar el Sistema (1-3 horas)
<asp:CheckBoxList runat="server" ID="Configurar">
<asp:ListItem ID="ECheckBox1" class="submenu" runat="server" Text="Personal"/>
<asp:ListItem ID="ECheckBox1a" class="submenu" runat="server" Text="Seguridad del Sistema"/>
<asp:ListItem ID="ECheckBox1b" class="submenu" runat="server" Text="Configuración del agencia (sitios, salones)"/>
<asp:ListItem ID="ECheckBox1c" class="submenu" runat="server" Text="Configuración de los módulos (elegibilidad, requisitos de salud)"/>
<asp:ListItem ID="ECheckBox1d" class="submenu" runat="server" Text="Configuración del sistema (preferencias, Campos de específicos a su agencia)"/>
<asp:ListItem ID="ECheckBox1e" class="submenu" runat="server" Text="Utilidades del Database (archivo, función de adiestramiento)"/>
<asp:ListItem ID="ECheckBox1f" class="submenu" runat="server" Text="Los datos de registro historia"/>
<asp:ListItem ID="ECheckBox1g" class="submenu" runat="server" Text="Configuración del PIR"/>
<asp:ListItem ID="ECheckBox1h" class="submenu" runat="server" Text="Configurar Data en vivo"/>
</asp:CheckBoxList>
On SubBtn.Click, the selected items would go into an email. I’m using this to loop through the first CheckBoxList:
Dim ConfigurarChkVal As String = String.Empty
For Each item As ListItem In Configurar.Items
If item.Selected Then
ConfigurarChkVal += item.Value + "<br />"
End If
Next
If Not [String].IsNullOrEmpty(ConfigurarChkVal) Then
ConfigurarChkVal = ConfigurarChkVal.Substring(1)
End If
Dim EmailBody As String
EmailBody = EmailBody + "<p style=" + "font-family:Verdana;" + ">" + ConfigurarChkVal + "</p>"
It returns:
Configurar el Sistema
ersonal
Seguridad del Sistema
Configuración del agencia (sitios, salones)
Configuración de los módulos (elegibilidad, requisitos de salud)
Configuración del sistema (preferencias, Campos de específicos a su agencia)
Utilidades del Database (archivo, función de adiestramiento)
Los datos de registro historia
Configuración del PIR
Configurar Data en vivo
So it cuts off the first letter of the first selected value. How do I solve this? It’s not really the main problem though — If I try to use the same code for the remaining CheckBoxLists, it only returns the last CheckBoxList instead of all 8 in the email.
I’m not sure if there’s an easier way, but any advice would be appreciated.
The code for all 8:
Dim EntradaChkVal As String = String.Empty
For Each item As ListItem In FamilyServices.Items
If item.Selected Then
EntradaChkVal += item.Value + "<br />"
End If
Next
If Not [String].IsNullOrEmpty(EntradaChkVal) Then
EntradaChkVal = EntradaChkVal.Substring(0)
End If
Dim HealthChkVal As String = String.Empty
For Each item As ListItem In Health.Items
If item.Selected Then
HealthChkVal += item.Value + "<br />"
End If
Next
If Not [String].IsNullOrEmpty(HealthChkVal) Then
HealthChkVal = HealthChkVal.Substring(0)
End If
Dim FamilyChkVal As String = String.Empty
For Each item As ListItem In FamServices.Items
If item.Selected Then
FamilyChkVal += item.Value + "<br />"
End If
Next
If Not [String].IsNullOrEmpty(FamilyChkVal) Then
FamilyChkVal = FamilyChkVal.Substring(0)
End If
Dim AdminChkVal As String = String.Empty
For Each item As ListItem In Admin.Items
If item.Selected Then
AdminChkVal += item.Value + "<br />"
End If
Next
If Not [String].IsNullOrEmpty(AdminChkVal) Then
AdminChkVal = AdminChkVal.Substring(0)
End If
Dim StatusChkVal As String = String.Empty
For Each item As ListItem In StatusCenter.Items
If item.Selected Then
StatusChkVal += item.Value + "<br />"
End If
Next
If Not [String].IsNullOrEmpty(StatusChkVal) Then
StatusChkVal = StatusChkVal.Substring(0)
End If
Dim ReportsChkVal As String = String.Empty
For Each item As ListItem In Informes.Items
If item.Selected Then
ReportsChkVal += item.Value + "<br />"
End If
Next
If Not [String].IsNullOrEmpty(ReportsChkVal) Then
ReportsChkVal = ReportsChkVal.Substring(0)
End If
Dim OptionalChkVal As String = String.Empty
For Each item As ListItem In Opciones.Items
If item.Selected Then
OptionalChkVal += item.Value + "<br />"
End If
Next
If Not [String].IsNullOrEmpty(OptionalChkVal) Then
OptionalChkVal = OptionalChkVal.Substring(0)
End If
I realized the issue was this:
EmailBody = EmailBody + “Configurar el Sistema ” + “
”
EmailBody = EmailBody + “” + ConfigurarChkVal + “
“
EmailBody = "<p style=" + "font-family:Verdana;" + "><p style=" + "font-family:Verdana;" + "><strong>Informacion de entrada para la familia y matriculados </strong> " + "</p><p></p>"
EmailBody = EmailBody + "<p style=" + "font-family:Verdana;" + ">" + EntradaChkVal + "</p>"
I left out the EmailBody + on each of the concurrent statements, which started the EmailBody over again.
Strings are indexed starting at zero so
ConfigurarChkVal.Substring(1)should beConfigurarChkVal.Substring(0)