我正在尝试执行以下代码,以在复选框中列出选择项
到邮件正文
Dim CheckedValues As String
For Each item In txt_panview0_ddinput1.Items
If item.checked Then
checkedValues = checkedValues & item.selectedValue
End If
Next
If Not String.IsNullOrEmpty(checkedValues) Then
checkedValues = checkedValues.Substring(1)
End If
tempCollector = tempCollector + "<br>" + "Area Name" + ": " + checkedValues
但我收到以下错误..
System.MissingMemberException: Public member 'checked' on type 'ListItem' not found.
at Microsoft.VisualBasic.CompilerServices.Symbols.Container.GetMembers(String& MemberName,
Boolean ReportErrors) at Microsoft.VisualBasic.CompilerServices.NewLateBinding.
LateGet(Object Instance, Type Type, String MemberName, Object[] Arguments, String[] ArgumentNames, Type[]
TypeArguments, Boolean[] CopyBack) at WebApplication1._Default.collectEmailBodyText()
in C:\UseFormCode\UseFormEnhWorking\Default.aspx.vb:line 271
请帮忙
答案 0 :(得分:1)
在检查是否已检查之前,将迭代中的每个项目交叉到 CheckBox
:
For Each item In txt_panview0_ddinput1.Items
dim c as CheckBox = Ctype(item.Value, CheckBox)
If c.checked Then
checkedValues = checkedValues & item.selectedValue
End If
Next
击> <击> 撞击>
要启用多个值的选择,请将SelectionMode
的{{1}}属性设置为ListBox
:
Multiple
然后迭代选定的值,使用以下内容:
<asp:ListBox ID="ListBox1" runat="server" SelectionMode="Multiple"></asp:ListBox>
PS我在VB.Net语法上有点生疏,所以我的代码可能在语法上不完美