J
Jeff
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<ProfileCommon> profileList = 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
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<ProfileCommon> profileList = 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