Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at

  • Bo Damgaard Mortensen 719 posts 1207 karma points
    Jan 22, 2011 @ 11:49
    Bo Damgaard Mortensen

    Set values in checkbox list programatically

    Hi all,

    I seem to have a bit of trouble to add values to the checkbox list style. I have done a search on the forum and on google, but it still doesn't work for me :/

    I have a set of prevalues for the checkbox list and I want to store the checked values on a given node when a frontend user clicks the "Save button"

    The following code should set the values:

    string listValues = string.Empty;
                foreach (ListItem listItem in cblCategories.Items)
                    if (listItem.Selected)
                        listValues += listItem.Value.ToString() + ',';
                if (listValues != string.Empty)
                    adDoc.getProperty("kategorier").Value = listValues;

    If I try to switch the datatype in Umbraco to a textstring instead of the checkbox list, it writes the values as expected! So eventually they are able to be stored after a postback - or so it seems ;)

    This is how I bind my checkbox list in Page_Load:

    if (!Page.IsPostBack)
        Node buySaleNode = new Node(1108);
            string cbl = buySaleNode.GetProperty("kategorier").Value;
            string[] categoryStrings = cbl.Split(',');
            cblCategories.DataSource = categoryStrings;

    I've also tried to bind the asp checkboxlist in the Page_Init event, but that didn't work either.

    Have I missed something here? :)

    Any hint/help on this is appreciated! Thanks!

    All the best,


  • Barry Fogarty 493 posts 1129 karma points
    Sep 03, 2011 @ 11:47
    Barry Fogarty

    Hi Bo I am also having this issue, I have changed to textstring and my comma delimited list is saved OK.  How did you end up resolving this?

  • Bo Damgaard Mortensen 719 posts 1207 karma points
    Sep 04, 2011 @ 10:56
    Bo Damgaard Mortensen

    Hi Barry,

    Glad you asked, I completely forgot about this post :-)

    The way I solved it was this:

    All the best,



  • Ranjit J. Vaity 66 posts 109 karma points
    Feb 26, 2022 @ 22:05
    Ranjit J. Vaity

    Hi Bo, The link does not work anymore. Can you help us with snippet here?

    Thank you!


  • Paul Griffiths 366 posts 1017 karma points
    Feb 12, 2014 @ 15:54
    Paul Griffiths

    Hi Barry

    How did you manage to do this? did you follow the article that Bo published?



Please Sign in or register to post replies

Write your reply to: