Solved

How to access ASP.Net user information from a colelction

Posted on 2007-12-03
5
494 Views
Last Modified: 2008-02-01
Greetings

I have a list box that needs to display a list of users (all, not just logged on). In  the panel on the right hand side I want to display the data (eg email address) related to the current user.

MembershipUserCollection allTheUsers;

     if (!IsPostBack)
        {
             allTheUsers= Membership.GetAllUsers();
            this.UsersListBox.DataSource = allTheUsers;
            this.UsersListBox.DataBind();
        }

My questions:

(1)  Is this the correct way to do it?
(2)  Having bound the collection to the listbox, how do I display only the username?
(3)  How do I get the value of (for example) the EMail field of the currently selected user?
(4)  If I add/delete a user, do I do another GetAllUsers()?  Is this acceptable? Is there a better way?

In advance, thanks!
0
Comment
Question by:allanmark
  • 3
5 Comments
 

Accepted Solution

by:
replylalit earned 425 total points
Comment Utility
http://www.informit.com/articles/article.aspx?p=351414&rl=1

This can help maybe?
You can easily retrieve the email username or anything from the listbox or from the collection. Refer to the article.
0
 
LVL 7

Expert Comment

by:nisarkhan
Comment Utility
one question at a time and you have 4 questions :)
0
 

Author Comment

by:allanmark
Comment Utility
Ok.

What is the proper way to do this. Should I post 4 individual questions?
0
 

Author Comment

by:allanmark
Comment Utility
Figured out (I think) question 3:-

muTheUser = mucAllTheUsers[lbxUsers.SelectedItem.Value];
 txtUser.Text     = muTheUser.UserName;
0
 

Author Comment

by:allanmark
Comment Utility
Ooops!!  Over eager - my effort isn't correct!!!
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now