Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0How do I get the profile data based on the userid?How do I get the profile data based on the userid?
Previous
 
Next
New Post
11/8/2006 6:50 AM
 

I would like to get the profile info of users.

What's wrong with this:

for j = 0 to 5

Dim UC As New UserController
Dim UP As New UserProfile
Dim UI As New UserInfo
Dim dUP As New DotNetNuke.Entities.Users.UserProfile
Dim dUI As New DotNetNuke.Entities.Users.UserInfo

uc.getuser(myportalid, j)

temp = UP.FirstName + UI.UserID.ToString + dUP.City + dUI.UserID.ToString

next

temp will always stay "-1-1"

How do I get the profile data based on the userid?

Thanks

 
New Post
11/9/2006 11:40 AM
 

Try something like...

Dim temp As String = ""

Dim j As Integer

For j = 0 To 5

   Try

      temp += "UserID: " & Users.UserController.GetUser(PortalId, j, True).UserID.ToString() & "<br>"

      temp += "UserName: " & Users.UserController.GetUser(PortalId, j, True).Username.ToString() & "<br>"

      temp += "First Name: " & Users.UserController.GetUser(PortalId, j, True).FirstName.ToString() & "<br>"

      temp += "Last Name: " & Users.UserController.GetUser(PortalId, j, True).LastName.ToString() & "<br>"

      temp += "Location: " & Users.UserController.GetUser(PortalId, j, True).Profile.City & ", "

      temp += Users.UserController.GetUser(PortalId, j, True).Profile.Region & " "

      temp += Users.UserController.GetUser(PortalId, j, True).Profile.PostalCode

      temp += "<br><br>"

   Catch ex As Exception

      temp += "UserID <b>" & j & "</b> does not exist in PortalID <b>" & PortalId & "</b><br><br>"

   End Try

Next

Label4.Text = temp

 

Note the Try/Catch block. If you are looping using a simple 0 to n index, you can not assume the indexed userid is in the portalid.  For example, 0 is not a valid userid. 1 is Host, 2 is Admin for PortalID 0, but 2 won't exist at all in PortalID 1. The better way to do this would be to pull an array of all the userids in the requested portal, then iterate through that array. Also, since you had your temp variable before the next loop, you are only setting the last value received. The -1-1 you got is from your ui.userid.tostring and dui.userid.tostring. You aren't passing j to userid anywhere, so it's picking up the anonymous user (-1).
 
New Post
11/9/2006 11:57 AM
 

I think this will be a bit cooler :)

Dim temp As StringBuilder = new StringBuilder();
Dim j As Integer
Dim dUI As New DotNetNuke.Entities.Users.UserInfo

For j = 0 To 5

   Try
      dUI = Users.UserController.GetUser(PortalId, j, True)

      temp.Append( "UserID: " & dUI.UserID.ToString() & "<br>")
      temp.Append(
"UserName: " & dUI.Username.ToString() & "<br>")
      
temp.Append( "First Name: " & dUIFirstName.ToString() & "<br>" )
      temp.Append( "Last Name: " & dUILastName.ToString() & "<br>");
      temp.Append( "Location: " & dUIProfile.City & ", ");
      temp.Append(  dUIProfile.Region & " ");
      temp.Append( dUIProfile.PostalCode);
      temp.Append(
"<br><br>");

   Catch ex As Exception

      temp += "UserID <b>" & j & "</b> does not exist in PortalID <b>" & PortalId & "</b><br><br>"

   End Try
Next
Label4.Text = temp.ToString();

 
New Post
11/9/2006 1:12 PM
 

Thank you Professor!  That was exactly what I was looking for.  Thanks also for your explanation.  That really helped. 

KG

 
New Post
11/16/2006 6:07 PM
 
Using string builder is much better then concatenate strings.
 
Previous
 
Next
HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0How do I get the profile data based on the userid?How do I get the profile data based on the userid?


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out