Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > MembershipCollection question

Reply
Thread Tools

MembershipCollection question

 
 
GaryDean
Guest
Posts: n/a
 
      07-03-2007
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



 
Reply With Quote
 
 
 
 
Cowboy \(Gregory A. Beamer\)
Guest
Posts: n/a
 
      07-03-2007
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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
>
>
>



 
Reply With Quote
 
 
 
 
Steven Cheng[MSFT]
Guest
Posts: n/a
 
      07-04-2007
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.


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
question row filter (more of sql query question) =?Utf-8?B?YW5kcmV3MDA3?= ASP .Net 2 10-06-2005 01:07 PM
Quick Question - Newby Question =?Utf-8?B?UnlhbiBTbWl0aA==?= ASP .Net 4 02-16-2005 11:59 AM
Question on Transcender Question :-) eddiec MCSE 6 05-20-2004 06:59 AM
Question re: features of the 831 router (also a 924 question) Wayne Cisco 0 03-02-2004 07:57 PM
Syntax Question - Novice Question sean ASP .Net 1 10-20-2003 12:18 PM



Advertisments