ASP.NET 2.0 ProfessionalIf you are an experienced ASP.NET programmer, this is the forum for your 2.0 questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.
You are currently viewing the ASP.NET 2.0 Professional section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
Thank you so much. Works like a charm. Only thing I am trying to do now is only select certain usernames. I put a usertype field in the aspnetdb users table and want to select only usernames that have this value set. Am I going in the right direction? I assume I need some sort of custom paramerter for the getallusers method.
Your help is GREATLY appreciated.
Unfortunately, that is not supported out of the box.
One easy way to do this is to put those users in a specific group and then change the call to Membership.GetAllUsers()
to
Roles.GetUsersInRole(roleName)
That gives you a list of the users in the specified role.
Otherwise, you need to create a custom method that returns a MembershipCollection. Inside this method you could fire a custom stored procedure that returns the users based on your criteria. You can take a look at the standard stored procedures and at the code for the standard SQL providers for some ideas on how to do this.
I do have all my users that I want to display in a Role (rolename ="Members"), just need a bit more explanation on how to configure the objectdatasource to show all users in role Members...
I changes ODS TypeName to System.Web.Security.Roles, the SelectMethod to GetUsersInRole(StringRolename,returns String[]) and set parameters as follows
<asp:Parameter DefaultValue="Members" Name="roleName" Type="String" />