German Wear Discount Shop - Click Here Write for Dotnet-friends and earn for your each submission [Dot]Net-Friends
Skip Navigation Links
Home
Latest
Fast Code
Articles
Tutorials
Online Resources
Forums
Login   | Hi, Guest


A Sorted List of Users on their Registration date using ASP .NET Membership Objects
Written By Omer Kamal On 03/02/2008

We will produce a piece of fast cod which will show that how can we create a Sorted List of users using Membership Objects of ASP .NET.

Views: 765
Rating: 4
Login to Rate
omerkamal
Tagged Under: ADO .NET, Database, Membership and Users Managment

Explanation:

First we are creating the  MembershipUserCollection Object and Filling it with All Registered users using Membership Object GetAllUsers(); method.

For creating the Sorted list we need a DataView Object which will be created through Filling a DataTable from all users data.

 

public DataView GetAllUsersDataTable()
{
     MembershipUserCollection mc = new MembershipUserCollection();
    mc = Membership.GetAllUsers();

    DataTable dt = new DataTable("LastUsers");
   dt.Columns.Add("UserName", typeof(string));
   dt.Columns.Add("Rdate", typeof(DateTime));

   foreach (MembershipUser st in mc)
  {
      dt.Rows.Add(new Object[] { st.UserName, st.CreationDate });
   }


   dt.AcceptChanges();
   DataView dv = new DataView(dt);
   return dv;
}

 

Now we will sort the DataView on users Registration data. (Descended i.e last registered 1st)

 

DataView tView = GetAllUsersDataTable();
tView.Sort = "Rdate DESC";

GridView1.DataSource = tView;
GridView1.DataBind();

Delicious Digg reddit reddit Technorati
About the Author:

@@ Omer Kamal is a Software Developer at Elanize KG Germany. He MSc. Mathematics from Islamia University Bahawalpur, Pakistan and Certified Developer from National Institute of Electronics Islamabad, Pakistan. He is Founder of FriendsPoint.de and Dotnet-Friends.com. He is currently Involved with Microsoft Office SharePoint 2007, Microsoft Dynamics CRM, BI Portal Solutions (Microsoft Dynamics Customization) and Web Security Solutions.
Check Omer Kamal Profile

Related Useful Links:
Visitors/Readers Comments
(for questions please use The Forum)



"Be the First to Comment!"


Add your Comments

Name:  
Message:
Note: For faster response please use Forums >> for your questions instead of the comments area! (Admin)