Problema al intentar recuperar datos de la casilla de verificación

votos
1

Estoy tratando de ejecutar el siguiente código para listar el elemento seleccionado en una casilla de verificación

al cuerpo del correo

 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

Pero recibo el siguiente error ...

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 

Por favor ayuda

Publicado el 30/07/2009 a las 15:13
fuente por usuario
En otros idiomas...                            


1 respuestas

votos
1

Escriba cada elemento de la iteración en a CheckBoxantes de verificar si está marcado:

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

Para habilitar la selección de valores múltiples, establezca la SelectionModepropiedad de ListBoxa Multiple:

<asp:ListBox ID="ListBox1" runat="server" SelectionMode="Multiple"></asp:ListBox>

Luego, para iterar sobre los valores seleccionados, use lo siguiente:

For Each item as ListItem In txt_panview0_ddinput1.Items
         If item.Selected Then
             CheckedValues = CheckedValues & item.Value
        End If
Next

PD. Estoy un poco oxidado en la sintaxis de VB.Net, por lo que mi código puede no ser sintácticamente perfecto

Respondida el 30/07/2009 a las 15:17
fuente por usuario

Cookies help us deliver our services. By using our services, you agree to our use of cookies. Learn more