Solved

View all users from MembershipUserCollection in WinForm project

Posted on 2007-03-23
1
983 Views
Last Modified: 2013-11-07
I am using Membership classes in windows forms project. I am trying to create a form that would show all users with the following code :
MembershipUserCollection
usersCol = Membership.GetAllUsers();
this.dataGridView1.DataSource = usersCol;
However dataGrid is blank even thought the collection has 8 items.

Even when I try to grab a user like that :
user = usersCol["TestOut"];
this.dataGridView1.DataSource = user;

dataGrid is empty.  
What is the best way to display users in WinForm project.
0
Comment
Question by:psokolo
1 Comment
 
LVL 3

Accepted Solution

by:
Nico earned 500 total points
ID: 18807419
It's not possible to databind a MembershipUserCollection, since it's not implementing the necessary interfaces. You can bind it when you copy the items in the collection to a normal array. (or ArrayList or maybe even some others I suppose)

The following code works perfectly for me:

MembershipUserCollection users = Membership.GetAllUsers();
MembershipUser[] userArray = new MembershipUser[users.Count];
users.CopyTo(userArray, 0);
dataGridView1.DataSource = userArray;
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.

820 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