locked
Membership problem RRS feed

  • Question

  • User-1922397443 posted

    hi, all

    I have 2 questions about membership:

    1. anybody know how to sort users in user_list.aspx page.

    2. in user_list.aspx page:

    the ObjectDataSource UserData TypeName is System.Web.Security.Membership,

    in GridView ListAllUsers Columns collection, datafield properties are UserName, Email

    but the System.Web.Security.Membership class has no UserName and Email properties

    can anyone know how the data are bound for UserName and Email

    Best Regards,

    Richard Yang 

    Monday, June 26, 2006 1:31 PM

All replies

  • User-1922397443 posted

    I have found the answers:

    Question 2:  System.Web.Security.Membership.GetAllUsers() returns MembershipUserCollection, the return value is a collection of MembershipUser, the MembershipUser has property UserName and Email. So the GridView field bound relays on the static method return value type T in List (of T), instead of property of TypeName in ObjectDataSource

    Question 1: the following idea is from Peter Kellner's blog, http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspp/html/ASP2memroleman.asp, thanks Peter Kellner, very nice acticle

     

     Because System.Web.Security.Membership is a none inherit class, so i made some changes

    1. create a MembershipUser Compaere for sorting

    2. create a MembershipWrapper to get all membership users and do sorting (you can write other membership functions in this wrapper according to requirement which pre-defined System.Web.Security.Membership can not do, like insert, update, delete, etc.) 

    3. change TypeName in ObjectDataSource to MembershipWrapper and add SortParamenter to ObjectDataSource, add sort expression to GridView columns, change GridView to AllowSorting)

    now, when you click column header in the gridview, the sorting funcationality is working. hope this can help somebody.

    'MembershipWrapper.vb

    Imports System.ComponentModel

    Imports System.Collections.Generic

    Namespace ASPNET.StarterKit.BusinessLogicLayer

    <DataObject(True)> _

    Public Class MembershipWrapper

    <DataObjectMethod(DataObjectMethodType.Select, True)> _

    Public Shared Function GetAllUsers() As List(Of MembershipUser)

    Dim memberList As New List(Of MembershipUser)

    Dim membershipUserCol As MembershipUserCollection = Membership.GetAllUsers

    For Each mu As MembershipUser In membershipUserCol

    memberList.Add(mu)

    Next

    Return memberList

    End Function

    <DataObjectMethod(DataObjectMethodType.Select, False)> _

    Public Shared Function GetAllUsers(ByVal sortPara As String) As List(Of MembershipUser)

    Dim memberList As List(Of MembershipUser) = GetAllUsers()

    memberList.Sort(New MembershipUserComparer(sortPara))

    Return memberList

    End Function

    End Class

    End Namespace

    best regards,

     

     

     

     

    Tuesday, June 27, 2006 12:16 PM
  • User555306248 posted
    thats nice[:)]
    Saturday, April 28, 2007 12:25 AM