jordanking
asked on
how to get user email and profile values for non logged in users from the user ID
hello,
I have a dropdown list on a page that has a list of users for an administrator where the bound data column is the user id. I am using the built in asp.net membership provider.
I want the administrator to be able to select a user and send them an email, which would be retrieved using the user id supplied. I need to have the userid as the bound column for other functions on the page.
So my question is, how do I get user information about non logged in users based on the supplied userid?
I have used the following to get a collection of all users:
but i just want to get info about one user, is there a way to do that, or do i have to loop through the entire user collection to find the one i want?
I have a dropdown list on a page that has a list of users for an administrator where the bound data column is the user id. I am using the built in asp.net membership provider.
I want the administrator to be able to select a user and send them an email, which would be retrieved using the user id supplied. I need to have the userid as the bound column for other functions on the page.
So my question is, how do I get user information about non logged in users based on the supplied userid?
I have used the following to get a collection of all users:
Dim muc As MembershipUserCollection
muc = Membership.GetAllUsers()
Dim mu As MembershipUser
For Each mu In muc
chrUsername = mu.UserName
Dim userProfile As ProfileCommon = ProfileCommon.Create(chrUsername, True)
''get user info here
Next
but i just want to get info about one user, is there a way to do that, or do i have to loop through the entire user collection to find the one i want?
Dim allUsers As MembershipUserCollection= Membership.GetAllUsers
Dim filteredUsers As UserInfoCollection = New MembershipUserCollection
If (UserRoles.SelectedIndex > 0) Then
' If we are filtering by role, get the users in the specified role
Dim usersInRole() As String = Roles.GetUsersInRole(UserR
' For each user in the role, add the user details to filteredUsers
For Each user As MembershipUser In allUsers
For Each userInRole As String In usersInRole
If (userInRole = user.UserName) Then
filteredUsers.Add(user)
Exit For
' Breaks out -avoid unneeded checking.
End If
Next
Next
Else
filteredUsers = allUsers
End If
' Bind the users to the Users GridView
DBUsers.DataSource = filteredUsers
DBUsers.DataBind
more detail;
http://www.4guysfromrolla.com/articles/052307-1.aspx
ASKER
That solution is the same as the example I posted. I want to get the profile information of one user based on their supplied userid. I just wondered if therev was a built in way of doing this. Otherwise I will have to create a custom function which I wanted to avoid
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
my initial solution i posted was what i had to use.
Dim filteredUsers As UserInfoCollection = New UserInfoCollection
If (UserRoles.SelectedIndex > 0) Then
' If we are filtering by role, get the users in the specified role
Dim usersInRole() As String = Roles.GetUsersInRole(UserR
' For each user in the role, add the user details to filteredUsers
For Each user As MembershipUser In allUsers
For Each userInRole As String In usersInRole
If (userInRole = user.UserName) Then
filteredUsers.Add(user)
Exit For
' Breaks out -avoid unneeded checking.
End If
Next
Next
Else
filteredUsers = allUsers
End If
' Bind the users to the Users GridView
DBUsers.DataSource = filteredUsers
DBUsers.DataBind
more detail;
http://www.4guysfromrolla.com/articles/052307-1.aspx