posted on January 19, 2020 08:20
public void GetRoles()
{
DotNetNuke.Security.Roles.RoleController rc = new DotNetNuke.Security.Roles.RoleController();
var myRoles = rc.GetRoles(this.PortalId);
// myRoles
ddlRoles.DataSource = myRoles;
ddlRoles.DataTextField = "RoleName";
ddlRoles.DataValueField = "RoleName";
ddlRoles.DataBind();
// ADD FIRST (NULL) ITEM
ListItem item = new ListItem();
item.Text = "-- Select Role to Assign --";
item.Value = "";
ddlRoles.Items.Insert(0, item);
// REMOVE DEFAULT ROLES
ddlRoles.Items.Remove("Administrators");
ddlRoles.Items.Remove("Registered Users");
ddlRoles.Items.Remove("Subscribers");
// REPORTS ROLE
ddlReportsRoles.DataSource = myRoles;
ddlReportsRoles.DataBind();
// ADD FIRST (NULL) ITEM
ListItem item1 = new ListItem();
item1.Text = "-- Select Role to View Reports --";
item1.Value = "";
ddlReportsRoles.Items.Insert(0, item1);
// REMOVE DEFAULT ROLES
ddlReportsRoles.Items.Remove("Administrators");
ddlReportsRoles.Items.Remove("Registered Users");
ddlReportsRoles.Items.Remove("Subscribers");
// MERGE ROLE
ddlMergeRoles.DataSource = myRoles;
ddlMergeRoles.DataBind();
// ADD FIRST (NULL) ITEM
item1.Value = "Select Role to Allow Merge";
ddlMergeRoles.Items.Insert(0, item1);
// REMOVE DEFAULT ROLES
ddlMergeRoles.Items.Remove("Administrators");
ddlMergeRoles.Items.Remove("Registered Users");
ddlMergeRoles.Items.Remove("Subscribers");
}