DataBindings with Checkboxes

3 posts, 1 answers
  1. Sternico
    Sternico avatar
    25 posts
    Member since:
    Sep 2009

    Posted 23 Aug 2012 Link to this post

    Hello,

    I'm trying to create a menu with RadPanelBar for showing groups of services, each group with their services associated. This menu has two levels, the parent level with the name of the group, and the child level with the name of the service. Because the user can select multiple services into a group, the child must be a Checkbox, and here I have the problem.

    At this moment I handle two options: I have a DataBindings with a RadPanelItemBinding that give me the structure parent-child with the data correctly formed, but without the checkboxes. I don't know how can I use another control into the DataBindings structure, neither if I can.

    In the other side, I have an ItemTemplate with the Checkboxes doing the same, but it doesn't differentiate the information about the parent and the child.

      <telerik:RadPanelBar ID="RadPanelBar1" runat="server" ExpandMode="SingleExpandedItem" DataFieldID="ID" DataFieldParentID="ParentID" Width="90%">
                <DataBindings>
                    <telerik:RadPanelItemBinding ImageUrlField="ImageUrl" TextField="Name" Expanded="True" ChildGroupHeight="200px" />
                </DataBindings>
                 
                <ItemTemplate>
                    <asp:CheckBox ID="CheckBox1" runat="server" Text='<%# ((ServicePanelbarContainer)Container.DataItem).Name %>'/>
                </ItemTemplate>
            </telerik:RadPanelBar>


    I'm binding the data to the RadPanelBar with this structure.

    Thanks for your help.

     int i = 1;
                foreach (ServiceGroup serviceGroup in groupList)
                {
                    serviceGroup.ImageUrl = "../../Img/Icons/" + serviceGroup.ImageUrl;
     
                    parsedGroupList.Add(new ServicePanelbarContainer()
                    {
                        ParentID = 0,
                        ID = i,
                        Name = serviceGroup.Name,
                        ImageUrl = serviceGroup.ImageUrl
                    });
                     
                    int j = i;
                    i++;
                     
                    foreach (Service s in serviceGroup.Service)
                    {
                        parsedGroupList.Add(new ServicePanelbarContainer()
                        {
                            ParentID = j,
                            ID = i,
                            Name = s.Name,
                            ImageUrl = ""
                        });
     
                        i++;
                    }
                }

    RadPanelBar1.DataSource = parsedGroupList;
    RadPanelBar1.DataBind();
  2. Answer
    Kate
    Admin
    Kate avatar
    1898 posts

    Posted 28 Aug 2012 Link to this post

    Hello Sternico,

    I prepared a very simplified runnable page where I implemented hierarchical databinding and applying templates to the child items only (as explained in the help article here).

    Kind regards,
    Kate
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Sternico
    Sternico avatar
    25 posts
    Member since:
    Sep 2009

    Posted 29 Aug 2012 Link to this post

    Thanks Kate, it was enough. With a few changes it works fine as I want.

    Regards.
Back to Top