Problemă în timp ce încearcă să preia date din caseta de selectare

voturi
1

Am încercat să execute codul de mai jos pentru a lista de selectare a elementului într-o casetă de selectare

la corpul de e-mail

 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

Dar eu sunt obtinerea următoarea eroare ..

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 

Te rog ajuta-ma

Întrebat 30/07/2009 la 15:13
sursa de către utilizator
În alte limbi...                            


1 răspunsuri

voturi
1

Typecast fiecare element din iterație la o CheckBoxînainte de a verifica dacă acesta este verificat:

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

Pentru a permite selectarea mai multe valori, setați SelectionModeproprietate a ListBoxla Multiple:

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

Apoi, pentru a itera peste valorile selectate, utilizați următoarele:

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

PS Sunt un pic ruginit pe sintaxa VB.Net astfel încât codul meu să nu fie perfectă sintactic

Publicat 30/07/2009 la 15:17
sursa de către utilizator

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