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

Collection of Profiles

P: n/a
Hey

asp.net 2.0

I want to populate a GridView with the profile properties off all users
registered on a website!

For example like this:
<profile enabled="true">
<properties>
<add name="FirstName" type="string"/>
<add name="LastName" type="string"/>
<add name="Gender" type="string"/>
<add name="BirthDate" type="DateTime"/>
</properties>
<profile>

Creating a GridView displaying the columns FirstName, LastName, Gender and
BirthDate...

My problem is that I don't know how to get the collection profiles.. The
only solution I can think of using a foreach loop on the MembershipUser
objects in MembershipUserCollection and create a ProfileCommon object for
each item in the MembershipCollection..:

List<ProfileCommonprofileList = null;
private MembershipUserCollection allUsers = Membership.GetAllUsers();
foreach (MembershipUser user in allUsers) {
ProfileCommon profile = Profile.GetProfile(user.UserName);
profileList.add(profile)
}
GridView1.DataSource = profileList;
GridView1.DataBind()

(I haven't tested the code above in visual studio 2005, so I'm not sure if
it compiles. I just wrote the code above to show what I whould do to get the
collection of profiles)

Isn't there a better way of doing this?

Jeff
Oct 26 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
If you want to get all the profiles, you should be able to retrieve all the
proviles through the ProfileManager.GetAllProfiles() method, which will
return a ProfileInfoCollection. I haven't tried binding this to a grid, but
I believe this could work.

--
Hope this helps,
Mark Fitzpatrick
Former Microsoft FrontPage MVP 199?-2006

"Jeff" <it************@hotmail.com.NOSPAMwrote in message
news:uU****************@TK2MSFTNGP04.phx.gbl...
Hey

asp.net 2.0

I want to populate a GridView with the profile properties off all users
registered on a website!

For example like this:
<profile enabled="true">
<properties>
<add name="FirstName" type="string"/>
<add name="LastName" type="string"/>
<add name="Gender" type="string"/>
<add name="BirthDate" type="DateTime"/>
</properties>
<profile>

Creating a GridView displaying the columns FirstName, LastName, Gender and
BirthDate...

My problem is that I don't know how to get the collection profiles.. The
only solution I can think of using a foreach loop on the MembershipUser
objects in MembershipUserCollection and create a ProfileCommon object for
each item in the MembershipCollection..:

List<ProfileCommonprofileList = null;
private MembershipUserCollection allUsers = Membership.GetAllUsers();
foreach (MembershipUser user in allUsers) {
ProfileCommon profile = Profile.GetProfile(user.UserName);
profileList.add(profile)
}
GridView1.DataSource = profileList;
GridView1.DataBind()

(I haven't tested the code above in visual studio 2005, so I'm not sure if
it compiles. I just wrote the code above to show what I whould do to get
the collection of profiles)

Isn't there a better way of doing this?

Jeff


Oct 26 '06 #2

P: n/a
Hey

I thought the same, but it doesn't quite work. Below is the code I tryed, it
crashes because "FirstName" isn't a property of ProfileInfo (it's one of the
properties specified in web.config in the profile section). I'm also
thinking that ProfileManager.GetAllProfiles returns a
ProfileMemberCollection, which contains a collection of ProfileInfo
objects.. I've been reading a bit here and see those custom properties is
available via the ProfileCommon class, but I don't know how to get a
collection of the ProfileCommon objects...

Any suggestions?

<asp:gridview ID="gvwUsers" runat="server" autogeneratecolumns="false" >
<Columns>
<asp:ButtonField HeaderText="UserName" DataTextField="UserName" />
<asp:ButtonField HeaderText="FirstName" DataTextField="FirstName" />
</Columns>
</asp:gridview>

protected void Page_Load(object sender, EventArgs e)
{
gvwUsers.DataSource =
ProfileManager.GetAllProfiles(ProfileAuthenticatio nOption.Authenticated);
gvwUsers.DataBind();
}

"Mark Fitzpatrick" <ma******@fitzme.comwrote in message
news:uX****************@TK2MSFTNGP03.phx.gbl...
If you want to get all the profiles, you should be able to retrieve all
the proviles through the ProfileManager.GetAllProfiles() method, which
will return a ProfileInfoCollection. I haven't tried binding this to a
grid, but I believe this could work.

--
Hope this helps,
Mark Fitzpatrick
Former Microsoft FrontPage MVP 199?-2006

"Jeff" <it************@hotmail.com.NOSPAMwrote in message
news:uU****************@TK2MSFTNGP04.phx.gbl...
>Hey

asp.net 2.0

I want to populate a GridView with the profile properties off all users
registered on a website!

For example like this:
<profile enabled="true">
<properties>
<add name="FirstName" type="string"/>
<add name="LastName" type="string"/>
<add name="Gender" type="string"/>
<add name="BirthDate" type="DateTime"/>
</properties>
<profile>

Creating a GridView displaying the columns FirstName, LastName, Gender
and BirthDate...

My problem is that I don't know how to get the collection profiles.. The
only solution I can think of using a foreach loop on the MembershipUser
objects in MembershipUserCollection and create a ProfileCommon object for
each item in the MembershipCollection..:

List<ProfileCommonprofileList = null;
private MembershipUserCollection allUsers = Membership.GetAllUsers();
foreach (MembershipUser user in allUsers) {
ProfileCommon profile = Profile.GetProfile(user.UserName);
profileList.add(profile)
}
GridView1.DataSource = profileList;
GridView1.DataBind()

(I haven't tested the code above in visual studio 2005, so I'm not sure
if it compiles. I just wrote the code above to show what I whould do to
get the collection of profiles)

Isn't there a better way of doing this?

Jeff



Oct 26 '06 #3

P: n/a
Hey

I've found the solution in this link
http://www.theserverside.net/tt/arti...eProvider.html

"Jeff" <it************@hotmail.com.NOSPAMwrote in message
news:Oo****************@TK2MSFTNGP05.phx.gbl...
Hey

I thought the same, but it doesn't quite work. Below is the code I tryed,
it crashes because "FirstName" isn't a property of ProfileInfo (it's one
of the properties specified in web.config in the profile section). I'm
also thinking that ProfileManager.GetAllProfiles returns a
ProfileMemberCollection, which contains a collection of ProfileInfo
objects.. I've been reading a bit here and see those custom properties is
available via the ProfileCommon class, but I don't know how to get a
collection of the ProfileCommon objects...

Any suggestions?

<asp:gridview ID="gvwUsers" runat="server" autogeneratecolumns="false" >
<Columns>
<asp:ButtonField HeaderText="UserName" DataTextField="UserName" />
<asp:ButtonField HeaderText="FirstName" DataTextField="FirstName" />
</Columns>
</asp:gridview>

protected void Page_Load(object sender, EventArgs e)
{
gvwUsers.DataSource =
ProfileManager.GetAllProfiles(ProfileAuthenticatio nOption.Authenticated);
gvwUsers.DataBind();
}

"Mark Fitzpatrick" <ma******@fitzme.comwrote in message
news:uX****************@TK2MSFTNGP03.phx.gbl...
>If you want to get all the profiles, you should be able to retrieve all
the proviles through the ProfileManager.GetAllProfiles() method, which
will return a ProfileInfoCollection. I haven't tried binding this to a
grid, but I believe this could work.

--
Hope this helps,
Mark Fitzpatrick
Former Microsoft FrontPage MVP 199?-2006

"Jeff" <it************@hotmail.com.NOSPAMwrote in message
news:uU****************@TK2MSFTNGP04.phx.gbl...
>>Hey

asp.net 2.0

I want to populate a GridView with the profile properties off all users
registered on a website!

For example like this:
<profile enabled="true">
<properties>
<add name="FirstName" type="string"/>
<add name="LastName" type="string"/>
<add name="Gender" type="string"/>
<add name="BirthDate" type="DateTime"/>
</properties>
<profile>

Creating a GridView displaying the columns FirstName, LastName, Gender
and BirthDate...

My problem is that I don't know how to get the collection profiles.. The
only solution I can think of using a foreach loop on the MembershipUser
objects in MembershipUserCollection and create a ProfileCommon object
for each item in the MembershipCollection..:

List<ProfileCommonprofileList = null;
private MembershipUserCollection allUsers = Membership.GetAllUsers();
foreach (MembershipUser user in allUsers) {
ProfileCommon profile = Profile.GetProfile(user.UserName);
profileList.add(profile)
}
GridView1.DataSource = profileList;
GridView1.DataBind()

(I haven't tested the code above in visual studio 2005, so I'm not sure
if it compiles. I just wrote the code above to show what I whould do to
get the collection of profiles)

Isn't there a better way of doing this?

Jeff




Oct 26 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.