0

I have a simple ASP checkbox list (see bellow):

   <asp:CheckBoxList ID="CheckBoxList1" runat="server">
                </asp:CheckBoxList>

I have a string in my vb.net (see bellow):

"1,2,3,4,5,6,7,8,9,10"

I want to be able to loop through each number in my string and add each one as a checkbox in my checkbox list. I have searched online though most solutions I have come across seem slightly different from what I want to achieve.

This is the code I have so far:

   For Each s In checkBoxString.split(",")
        Next

I was wondering if anyone could give me any suggestions to how I can achieve this. Any help is appreciated, Thank you in advance.

1 Answer 1

1

You need to create a ListItem and add it to the list of CheckBoxList items:

For Each s In checkBoxString.split(",")
    CheckBoxList1.Items.Add(New ListItem(s))
Next
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.