Create a DataTable of All User in your Website

Written by omerkamal on Mar 23, 2007
Creaing a DataTable of all members using ASP .NET 2.0

Explanation:

  • Use Membership.GetAllUsers(); to get all users in your website.
  • Create MembershipUserCollection for Iterating over all users.
  • Call AcceptChanges on the DataTable to do transection of the Data

Public static DataTable GetAllUsersDataTable()
    {
        MembershipUserCollection mc = Membership.GetAllUsers();
 
        DataTable dt = new DataTable("LastUsers");
        dt.Columns.Add("UserName", typeof(string));
        dt.Columns.Add("Rdate", typeof(DateTime));
        string name = string.Empty;
        foreach (MembershipUser st in mc)
        {
            name = st.UserName;
            dt.Rows.Add(new Object[] { name, st.CreationDate });
        }
        dt.AcceptChanges();
     
        return dt;
    }
Visitors/Readers Comments
(for questions please use The Forum)



Balamurugan
 Very wonderful short and simple

24/04/2007 11:51:34 UTC

kamal

Just like a Fast Food  ( also, could effect bad if get used to it  )

Some time, we know the theory but just need to grab the API's this is what FAST CODE about. Of course, we will not recommend this to newbies.

24/04/2007 14:46:23 UTC

HGKMSD
you should just  give us a empty table to write in
that is all i am asking for

13/11/2008 17:30:42 UTC




Add your Comments

Name:  
Message:


Advertise Here
For more details
Contact Us

Advertisments