By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,294 Members | 2,681 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,294 IT Pros & Developers. It's quick & easy.

determine if item is in array, how??

P: n/a
ASP.NET 2.0

Below are some code from my webproject. What I'm trying to do is create a
MembershipUserCollection which holds users of the role "member"

this line:
string[] role = Roles.GetRolesForUser(user.UserName);
generates an array consisting of the roles belonging to the user. I'm a bit
stuck here. I need to quickly determine if this array have an item named
"member" within it... I know I can just create a simple for loop and loop
through the entire array but I hope there is some kind of direct access like
for example role["member"]...

MembershipUserCollection allUsers = Membership..GetAllUsers();
MembershipUserCollection members = new MembershipUserCollection();
foreach (MembershipUser user in allUsers)
{
string[] role = Roles.GetRolesForUser(user.UserName);
role.
}

any suggestions? Maybe you have a better way of getting the users belonging
to a role, then
please share it with me :-)

Best Regards

Jeff
Mar 9 '07 #1
Share this Question
Share on Google+
2 Replies


P: n/a
use a Hashtable or Dictionary instead of an array.

-- bruce (sqlwork.com)

Jeff wrote:
ASP.NET 2.0

Below are some code from my webproject. What I'm trying to do is create a
MembershipUserCollection which holds users of the role "member"

this line:
string[] role = Roles.GetRolesForUser(user.UserName);
generates an array consisting of the roles belonging to the user. I'm a bit
stuck here. I need to quickly determine if this array have an item named
"member" within it... I know I can just create a simple for loop and loop
through the entire array but I hope there is some kind of direct access like
for example role["member"]...

MembershipUserCollection allUsers = Membership..GetAllUsers();
MembershipUserCollection members = new MembershipUserCollection();
foreach (MembershipUser user in allUsers)
{
string[] role = Roles.GetRolesForUser(user.UserName);
role.
}

any suggestions? Maybe you have a better way of getting the users belonging
to a role, then
please share it with me :-)

Best Regards

Jeff

Mar 9 '07 #2

P: n/a
In your source enter HttpContext.Current.User and use Intellisense to review
the properties available. There are two you may find useful.
--
<%= Clinton Gallagher
NET csgallagher AT metromilwaukee.com
URL http://clintongallagher.metromilwaukee.com/
MAP http://wikimapia.org/#y=43038073&x=-...8&z=17&l=0&m=h
"Jeff" <it************@hotmail.com.NOSPAMwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
ASP.NET 2.0

Below are some code from my webproject. What I'm trying to do is create a
MembershipUserCollection which holds users of the role "member"

this line:
string[] role = Roles.GetRolesForUser(user.UserName);
generates an array consisting of the roles belonging to the user. I'm a
bit stuck here. I need to quickly determine if this array have an item
named "member" within it... I know I can just create a simple for loop and
loop through the entire array but I hope there is some kind of direct
access like for example role["member"]...

MembershipUserCollection allUsers = Membership..GetAllUsers();
MembershipUserCollection members = new MembershipUserCollection();
foreach (MembershipUser user in allUsers)
{
string[] role = Roles.GetRolesForUser(user.UserName);
role.
}

any suggestions? Maybe you have a better way of getting the users
belonging to a role, then
please share it with me :-)

Best Regards

Jeff

Mar 9 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.