How to group CheckboxList?

Discussion in 'ASP .Net Web Controls' started by Egbert, Nov 3, 2004.

  1. Egbert

    Egbert Guest

    I use a System.Web.UI.WebControls.CheckBoxList object to fill a list.

    I need to label groups of checkboxes in the list by Category (Determined
    dynamically from the database) at runtime.

    Is it possible to group checkboxes in 1 CheckboxList?

    Something like this:

    *************************

    Category 1
    -checkbox1
    -checkbox2

    Category 2
    -checkbox3
    -checkbox4

    Category 3
    -checbox5

    *************************
    Egbert, Nov 3, 2004
    #1
    1. Advertising

  2. There isn't any default grouping. You'd have to customize the control's
    rendering
    in order to provide this feature. Won't be exceptionally easy to do this using
    the
    existing control, so you might want to create your own control.


    --
    Justin Rogers
    DigiTec Web Consultants, LLC.
    Blog: http://weblogs.asp.net/justin_rogers

    "Egbert" <a> wrote in message
    news:4188ac78$0$21253$...
    >I use a System.Web.UI.WebControls.CheckBoxList object to fill a list.
    >
    > I need to label groups of checkboxes in the list by Category (Determined
    > dynamically from the database) at runtime.
    >
    > Is it possible to group checkboxes in 1 CheckboxList?
    >
    > Something like this:
    >
    > *************************
    >
    > Category 1
    > -checkbox1
    > -checkbox2
    >
    > Category 2
    > -checkbox3
    > -checkbox4
    >
    > Category 3
    > -checbox5
    >
    > *************************
    >
    >
    >
    Justin Rogers, Nov 3, 2004
    #2
    1. Advertising

  3. Egbert

    Egbert Guest

    You mean by using a Repeater or Datagrid?

    But then it is difficult to determine which boxes are checked, and which
    aren't, when you want to persist de results.

    In case of 1 checkboxlist, you can loop through the items of the
    checkboxlist.

    I also tried to group de checkboxes by giving them the same name, like in
    HTML, but that doesn't seem to be possible with <asp:checkbox> elements.


    "Justin Rogers" <> wrote in message
    news:%...
    > There isn't any default grouping. You'd have to customize the control's
    > rendering
    > in order to provide this feature. Won't be exceptionally easy to do this
    > using the
    > existing control, so you might want to create your own control.
    >
    >
    > --
    > Justin Rogers
    > DigiTec Web Consultants, LLC.
    > Blog: http://weblogs.asp.net/justin_rogers
    >
    > "Egbert" <a> wrote in message
    > news:4188ac78$0$21253$...
    >>I use a System.Web.UI.WebControls.CheckBoxList object to fill a list.
    >>
    >> I need to label groups of checkboxes in the list by Category (Determined
    >> dynamically from the database) at runtime.
    >>
    >> Is it possible to group checkboxes in 1 CheckboxList?
    >>
    >> Something like this:
    >>
    >> *************************
    >>
    >> Category 1
    >> -checkbox1
    >> -checkbox2
    >>
    >> Category 2
    >> -checkbox3
    >> -checkbox4
    >>
    >> Category 3
    >> -checbox5
    >>
    >> *************************
    >>
    >>
    >>

    >
    >
    Egbert, Nov 3, 2004
    #3
  4. The CheckBoxList actually gives each checkbox a unique number
    based on index. They are doing some work. The point is, if you
    want this feature, you are going to have to get an existing control
    or write your own logic.

    ListControl is a good base class to start from. Or CheckBoxList
    if you just override the rendering logic. Otherwise, you could use
    your own Repeater, since that is pretty much what the CheckBoxList
    does already.


    --
    Justin Rogers
    DigiTec Web Consultants, LLC.
    Blog: http://weblogs.asp.net/justin_rogers

    "Egbert" <a> wrote in message
    news:4188ba1d$0$21255$...
    > You mean by using a Repeater or Datagrid?
    >
    > But then it is difficult to determine which boxes are checked, and which
    > aren't, when you want to persist de results.
    >
    > In case of 1 checkboxlist, you can loop through the items of the checkboxlist.
    >
    > I also tried to group de checkboxes by giving them the same name, like in
    > HTML, but that doesn't seem to be possible with <asp:checkbox> elements.
    >
    >
    > "Justin Rogers" <> wrote in message
    > news:%...
    >> There isn't any default grouping. You'd have to customize the control's
    >> rendering
    >> in order to provide this feature. Won't be exceptionally easy to do this
    >> using the
    >> existing control, so you might want to create your own control.
    >>
    >>
    >> --
    >> Justin Rogers
    >> DigiTec Web Consultants, LLC.
    >> Blog: http://weblogs.asp.net/justin_rogers
    >>
    >> "Egbert" <a> wrote in message
    >> news:4188ac78$0$21253$...
    >>>I use a System.Web.UI.WebControls.CheckBoxList object to fill a list.
    >>>
    >>> I need to label groups of checkboxes in the list by Category (Determined
    >>> dynamically from the database) at runtime.
    >>>
    >>> Is it possible to group checkboxes in 1 CheckboxList?
    >>>
    >>> Something like this:
    >>>
    >>> *************************
    >>>
    >>> Category 1
    >>> -checkbox1
    >>> -checkbox2
    >>>
    >>> Category 2
    >>> -checkbox3
    >>> -checkbox4
    >>>
    >>> Category 3
    >>> -checbox5
    >>>
    >>> *************************
    >>>
    >>>
    >>>

    >>
    >>

    >
    >
    Justin Rogers, Nov 3, 2004
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. JD
    Replies:
    5
    Views:
    11,638
    NetArchitect
    Aug 8, 2007
  2. Patrick.O.Ige
    Replies:
    5
    Views:
    19,100
    Patrick.O.Ige
    Jun 19, 2005
  3. Akaketwa
    Replies:
    1
    Views:
    4,876
    impaler
    Sep 22, 2006
  4. Replies:
    0
    Views:
    525
  5. Egbert

    Howto group checkboxes in CheckBoxList

    Egbert, Nov 2, 2004, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    126
    Egbert
    Nov 2, 2004
Loading...

Share This Page