Create RadpanelItems with CheckBoxList inside programatically...

1 posts, 0 answers
  1. Cesar
    Cesar avatar
    5 posts
    Member since:
    Dec 2011

    Posted 18 Feb 2012 Link to this post

    Can someone help with this..
    I have a a RadPanelBar that im programatically populating with RadPanelItems, and 1 CheckBoxList inside of each radpanelItem.
    Below is the the code i sue to pull data from a dataset and create RadpanelItem and its checkboxlist child:
    //Loading Permission Tabs
    PermissionDataSet PermissionsDS = _PermissionFactory.PermissionSelectDynamicWithTables("", "", "[dbo].[Permission].[Type],[dbo].[Permission].[Name]");
    string PermissionType = "";

               //Loading DS and creating RadPanelItem/CheckboxList
                for (int x = 0; x < PermissionsDS.Permission.Rows.Count; x++) {
                    PermissionDataSet.PermissionRow PermissionRow = (PermissionDataSet.PermissionRow)PermissionsDS.Permission.Rows[x];
                        RadPanelItem ThisRadPanelItem = new RadPanelItem();
                        ThisRadPanelItem.Value = PermissionRow.Type;
                        ThisRadPanelItem.Text = PermissionRow.Type;
                        CheckBoxList ThisCheckBoxList =  new CheckBoxList();
                        ThisCheckBoxList.RepeatColumns = 8;
                        ThisCheckBoxList.RepeatDirection = RepeatDirection.Horizontal;
                        ThisCheckBoxList.CssClass = "3column";
                        //Loading Permission Items
                        PermissionDataSet ThisPermissionsDS = _PermissionFactory.PermissionSelectDynamicWithTables("", "[dbo].[Permission].[Type] = '" + PermissionRow.Type + "'", "[dbo].[Permission].[Name]");
                        if (EditMode)
                            for (int y = 0; y < ThisPermissionsDS.Permission.Rows.Count; y++)
                                int PermissionId = int.Parse(ThisPermissionsDS.Permission.Rows[y]["Id"].ToString());
                                string PermissionName = ThisPermissionsDS.Permission.Rows[y]["Name"].ToString();
                                RolePermissionDataSet.RolePermissionRow ThisRolePermissionRow = _RolePermissionFactory.RolePermissionSelectByRoleIdAndPermissionId((int)_SelectedRole.Id, PermissionId);
                                ListItem ThisListItem = new ListItem();
                                ThisListItem.Text = PermissionName;
                                ThisListItem.Value = PermissionId.ToString();
                                if (ThisRolePermissionRow != null) ThisListItem.Selected = true;
                            ThisCheckBoxList.DataSource = ThisPermissionsDS;
                            ThisCheckBoxList.DataTextField = "Name";
                            ThisCheckBoxList.DataValueField = "Id";
                        ThisCheckBoxList.ID = "ThisCheckBoxList";
                        ThisRadPanelItem.Expanded = true;
                        ThisRadPanelItem.CssClass = "RadPanelBarPageContent";


                        PermissionType = PermissionRow.Type;

    OK the important part is how i attach the radpanelitem and checkbox to the radpanel bar as you can see bolded above, and it all works well. The page loads with all radpanelitems inserted and 1 checboxlist inside of each radpanelitem.

    When i try to consume the whole radpanelbar with a loop, to check which items on the checboxlist are selected, I CANT FIND THE CHECKBOX LIST,  eventhought im able to select the radpanelitem, code below:

     ffor (int x = 0; x < RadPanelBarPermissions.Items.Count; x++)
                            //RadPanelItem ThisPanelItem = RadPanelBarPermissions.FindItemByValue("");
                            RadPanelItem ThisPanelItem = (RadPanelItem)RadPanelBarPermissions.Items[x]; THIS WORKS
                            CheckBoxList ThisCheckBoxList = (CheckBoxList)RadPanelBarPermissions.Items[x].FindControl("ThisCheckBoxList"); THIS DOES NOT WORK, Checkboxlist returns null...
    Youll see in the picture that the controls load normal after icreate them, but when i try to acces them, the ceckboxlist is gone!!!!
    Please help!!!

    Thank You.
Back to Top