Welcome to WebmasterWorld Guest from 54.198.92.22

Forum Moderators: ocean10000

Message Too Old, No Replies

Problem with getting current users

     
7:04 pm on Aug 24, 2009 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:June 10, 2008
posts: 1130
votes: 0


I am trying to create a dropdown of usernames in a membership system. It is so the administrator can remove users by selecting their username and clicking delete. When I got the the asp configuration option it only shows one users. However if I select username from aspnet_users there are still like 5 users in there. I tried deleting them with the membership.deleteuser(user.identity.name, true) function and the aspnet configuraiton sees them as gone but they are still in that table. Does anyone know why and how I can get the all of the current users binded to a dropdown? Thanks
7:28 pm on Aug 24, 2009 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Feb 1, 2005
posts:732
votes: 0


I assumed Membership.DeleteUser(userName, true) deleted everything as deleteAllRelatedData is set to true, but I'm not sure why it is not working as expected. (I have not tested it though)

To bind all users to a DropDown you can use the following code:

Add a dropdown to the codebefore:

<asp:DropDownList ID="DropDownList1" runat="server"></asp:DropDownList>

In code behind add the following:

DropDownList1.DataSource = Membership.GetAllUsers()
DropDownList1.DataBind()
7:46 pm on Aug 24, 2009 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:June 10, 2008
posts:1130
votes: 0


I thought I already tried that but it seems to work now. I have no idea why. Maybe I need to work on another project for a while. Thanks,
7:52 pm on Aug 24, 2009 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Feb 1, 2005
posts:732
votes: 0


I just tested with Membership.DeleteUser("userName", True), and it is removing the user from the aspnet_Users table.

It may be related to deleting the currently logged in user in your code with user.identity.name.

Are you using a custom Membership provider? that could also cause unexpected behaviour.