I have programmatically bind repeater in my code behind file. I am also checking for roles in my page like below and according to that I am binding my repeater control like this;
if (Page.User.IsInRole("Admin"))
{
repeaterArticlesList.DataSource = ArticleAccess.GetArticlesWithNoPaginate();
repeaterArticlesList.DataBind();
}
else if(Page.User.IsInRole("Editor"))
{
repeaterArticlesList.DataSource = ArticleAccess.GetArticlesWithNoPaginate();
repeaterArticlesList.DataBind();
}
else
{
string userName = Page.User.Identity.Name.ToString();
repeaterArticlesList.DataSource = ArticleAccess.GetArticlesWithNoPaginateWithUsername(userName);
repeaterArticlesList.DataBind();
}
I have total 4 roles i-e Admin, Author, Editor, User. However, I have one user i-e admin which belongs to all of these roles.
The problem with my logic is that when I logged in as an admin user (which belongs to all 4 roles), the first condition and the second condition both fails and the last one is executed.
So, I want to execute my first condition for that user which must be in all of my roles 4 roles.
Otherwise then I will check for individual roles.
Any help regard to this is appreciated in advance.
You could do something like: