protected DataTable ConvertToRolePermissionsBindingTable(ThinkgatePermissionsCollection permissions, ThinkgateRole role)
		{
			DataTable table = new DataTable();
            table.Columns.Add(new DataColumn("ID", typeof(System.Guid)));
            table.Columns.Add(new DataColumn("ParentID", typeof(System.Guid)));
			table.Columns.Add(new DataColumn("Name", typeof(string)));
			table.Columns.Add(new DataColumn("Member", typeof(bool)));
			table.Columns.Add(new DataColumn("PermissionLevelValue", typeof(int)));
			table.Columns.Add(new DataColumn("Description", typeof(string)));

			foreach (ThinkgatePermission permission in permissions)
			{
				DataRow row = table.NewRow();
                row["ID"] = permission.PermissionId;
				row["ParentID"] = permission.ParentPermissionId;
				row["Name"] = permission.PermissionName;
				row["Member"] = role.PermissionsHT.Contains(permission);
				row["PermissionLevelValue"] = role.PermissionsHT.Contains(permission) ? role.PermissionsHT.GetPermission(permission.ToString()).PermissionLevelValue : DataIntegrity.ConvertToInt(ThinkgatePermission.PermissionLevelValues.NoValue.ToString());
				row["Description"] = permission.Description;
				table.Rows.Add(row);
			}
			return table;
		}
        protected void rtlPricingModulePermissionsForEditing_NeedDataSource(object sender, TreeListNeedDataSourceEventArgs e)
        {
            int pricingModuleID = DataIntegrity.ConvertToInt(Request.QueryString["ID"]);
            if (pricingModuleID == 0) return;

            ThinkgatePermissionsCollection permissions = new ThinkgatePermissionsCollection();
            permissions.GetPermissionsCollection(PermissionCollectionTypes.All, 1);
            ThinkgatePricingModule pricingModule = new ThinkgatePricingModule(pricingModuleID);
            lblHeaderItemID.Text = pricingModule.Id.ToString();
            lblHeaderItemName.Text = String.Format("Permissions in {0}  Pricing Module:", pricingModule.Name);

            rtlPricingModulePermissionsForEditing.DataSource = ConvertToPricingModulePermissionsBindingTable(permissions, pricingModule);

        }
 protected void rgPermissions_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
 {
     ThinkgatePermissionsCollection permissions = new ThinkgatePermissionsCollection();
     permissions.GetPermissionsCollection(PermissionCollectionTypes.All, 1);
     rgPermissions.DataSource = permissions.Permissions;
 }
        protected void rtlRolePermissionsForEditing_NeedDataSource(object sender, TreeListNeedDataSourceEventArgs e)
        {
            Guid roleID = new Guid();
            Guid.TryParse(Request.QueryString["ID"], out roleID);
            if (roleID == default(Guid)) return;

            ThinkgatePermissionsCollection permissions = new ThinkgatePermissionsCollection();
            permissions.GetPermissionsCollection(PermissionCollectionTypes.All, 1);
            ThinkgateRole role = new ThinkgateRole(roleID);
            lblHeaderItemID.Text = role.RoleId.ToString();
            lblHeaderItemName.Text = String.Format("Permissions in {0}  Role:", role.RoleName);

            DataTable test  = ConvertToRolePermissionsBindingTable(permissions, role);
            rtlRolePermissionsForEditing.DataSource = test;
        }
 protected void LoadPermissions()
 {
     ThinkgatePermissionsCollection permissions = new ThinkgatePermissionsCollection();
     permissions.GetPermissionsCollection(PermissionCollectionTypes.All, 1);
     rgPermissions.DataSource = permissions.Permissions;
     rgPermissions.DataBind();
 }