我正在创建一个包含多个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>"
它返回:
Configurar el Sistema
叫做Personal
Seguridad del Sistema
Configuracióndelagencia(sitios,salones)
Configuracióndelosmódulos(elegibilidad,requisitos de salud)
Configuracióndelsistema(preferencias,Camposdeespecíficosasu agencia)
Utilidades del Database(archivo,funcióndeadiestramiento)
Los datos de registro historia
ConfiguracióndelPIR
Configurar数据体内
因此它会切断第一个选定值的第一个字母。我该如何解决这个问题?这不是真正的主要问题 - 如果我尝试对剩余的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。
答案 0 :(得分:0)
字符串从零开始编制索引,因此ConfigurarChkVal.Substring(1)
应为ConfigurarChkVal.Substring(0)