Read an Arraylist and print the values with a checkbox

Posted on 2009-02-13
Last Modified: 2012-05-06
I want to loop through an arraylist and show each value on the form with a checkbox in front of the value.

eg :- Arraylist contains


on the form i want it as

'checkbox' item1
'checkbox' item2
'checkbox' item3
Question by:pratikshahse
    LVL 27

    Expert Comment

    So you want to add checkbox controls dynamically for each entry in an array list?
    LVL 5

    Accepted Solution

    Add a CheckBoxList on your form.
    Assuming id of the checklist box just added is cbList.
    Assuming itemsArrayList is the arraylist.

    In your code behind, write this code:

    foreach (string str in itemsArrayList)
        ListItem item = new ListItem(str, str);

    Open in new window

    LVL 1

    Expert Comment


    For each Str as String in ArrayList

    Open in new window


    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
    Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
    This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA.…
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

    734 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now