MembershipCollection question

Discussion in 'ASP .Net' started by GaryDean, Jul 3, 2007.

  1. GaryDean

    GaryDean Guest

    The static MembershipCollection class appears to work different than other
    collection classes...

    MembershipUserCollection myUsers = new MembershipUserCollection();
    myUsers = Membership.GetAllUsers();
    MembershipUser myMember = myUsers.Item[0]; <---- no Item property

    This collection has no Item property. Why? The only way I can reference an
    individual member of this collection is to specify the string value of the
    key field (in this case username).

    Thanks,
    Gary
    GaryDean, Jul 3, 2007
    #1
    1. Advertising

  2. It is designed to be used with the user name, so leaving it out is not as
    strange as it might seem.

    If you absolutely need an indexer, consider creating a custom provider and
    have it call most of the underlying methods except add a publicly exposed
    indexer.

    --
    Gregory A. Beamer
    MVP; MCP: +I, SE, SD, DBA
    http://gregorybeamer.spaces.live.com
    Co-author: Microsoft Expression Web Bible (upcoming)

    ************************************************
    Think outside the box!
    ************************************************
    "GaryDean" <> wrote in message
    news:...
    > The static MembershipCollection class appears to work different than other
    > collection classes...
    >
    > MembershipUserCollection myUsers = new MembershipUserCollection();
    > myUsers = Membership.GetAllUsers();
    > MembershipUser myMember = myUsers.Item[0]; <---- no Item property
    >
    > This collection has no Item property. Why? The only way I can reference
    > an individual member of this collection is to specify the string value of
    > the key field (in this case username).
    >
    > Thanks,
    > Gary
    >
    >
    >
    Cowboy \(Gregory A. Beamer\), Jul 3, 2007
    #2
    1. Advertising

  3. Hi Gary,

    As Gregory has mentioned here, since MembershipUser instances are mainly
    identified through their username, and index based locator doesn't help
    much in the collection, so the MembershipuserCollection class doesn't
    implement the index based accessor. However, if you do need index based
    access to a list of MembershipUser objects, you can use the
    "MembershipUserCollection.CopyTo" method to copy the list into a
    MembershipUser[] array and access them through index based pattern.

    Sincerely,

    Steven Cheng

    Microsoft MSDN Online Support Lead


    This posting is provided "AS IS" with no warranties, and confers no rights.
    Steven Cheng[MSFT], Jul 4, 2007
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. sean
    Replies:
    1
    Views:
    573
    Cowboy \(Gregory A. Beamer\)
    Oct 20, 2003
  2. =?Utf-8?B?UnlhbiBTbWl0aA==?=

    Quick Question - Newby Question

    =?Utf-8?B?UnlhbiBTbWl0aA==?=, Feb 14, 2005, in forum: ASP .Net
    Replies:
    4
    Views:
    636
    Iain Norman
    Feb 16, 2005
  3. =?Utf-8?B?YW5kcmV3MDA3?=

    question row filter (more of sql query question)

    =?Utf-8?B?YW5kcmV3MDA3?=, Oct 5, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    929
    Scott Allen
    Oct 6, 2005
  4. Philip Meyer
    Replies:
    0
    Views:
    406
    Philip Meyer
    Nov 30, 2003
  5. Bit Byte
    Replies:
    1
    Views:
    819
    Teemu Keiski
    Jan 28, 2007
Loading...

Share This Page