0

我正在创建一个包含多个 CheckBoxLists(总共 8 个)的表单,如下所示:

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>

在 SubBtn.Click 上,所选项目将进入电子邮件。我正在使用它来循环第一个 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>"

它返回:

配置系统

个人的

安全保障

Configuración del agencia (sitios, 沙龙)

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)

历史数据

PIR 配置

体内配置数据

所以它切断了第一个选定值的第一个字母。我该如何解决这个问题?但这并不是真正的主要问题——如果我尝试对剩余的 CheckBoxLists 使用相同的代码,它只会返回最后一个 CheckBoxList 而不是电子邮件中的全部 8 个。

我不确定是否有更简单的方法,但任何建议都将不胜感激。


所有 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

我意识到问题是这样的: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>"

我在每个并发语句上都省略了 EmailBody +,这又重新启动了 EmailBody。

4

1 回答 1

0

字符串从零开始索引,所以 ConfigurarChkVal.Substring(1)应该是ConfigurarChkVal.Substring(0)

于 2013-02-08T23:47:50.457 回答