Reputation: 3950
I'm using the default ASP.NET profile and membership provider. I want to create a ASP List View with the name of the user and their role. When I try using this functionality I get a error:
Code behind:
public List<aspnet_Users> GetUsers(int startRowIndex, int maximumRows)
{
this.entities.aspnet_Users.Include("aspnet_Roles").OrderBy(u => u.UserId).Skip(startRowIndex).Take(maximumRows).ToList();
}
Page directive:
<%# Eval("aspnet_Roles.RoleName")%>
It's not working because it's a many to many relationship in the database. How do I change my code behind method to map across the many to many relationship?
Upvotes: 0
Views: 262
Reputation: 126587
Don't do this. You shouldn't map the membership tables. The ASP.NET membership API already has a method to get a page of member data. You're reinventing the wheel, and replacing it with a version where you can't change the tire.
Upvotes: 2