Wrox Programmer Forums
|
BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0
This is the forum to discuss the Wrox book ASP.NET 2.0 Website Programming: Problem - Design - Solution by Marco Bellinaso; ISBN: 9780764584640
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 29th, 2008, 09:28 PM
Authorized User
 
Join Date: Sep 2007
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Default How i can select data from user profiles

if i want to select data from user profiles such as member who live in thailand ,or member who have occupation is "xxxxx" and so on how i can do this.
                                                 thank

 
Old April 30th, 2008, 11:57 AM
Lee Dumond's Avatar
Wrox Author
 
Join Date: Jan 2008
Posts: 923
Thanks: 12
Thanked 166 Times in 162 Posts
Default

I think the easiest way to do this would be to loop through all of the users, getting their profiles, and checking the profile property you are interested in for the criterion you specify (for example, if the country is Thailand). For display purposes, you could add each matching user to a collection and bind that to a GridView.

 
Old April 30th, 2008, 01:17 PM
Lee Dumond's Avatar
Wrox Author
 
Join Date: Jan 2008
Posts: 923
Thanks: 12
Thanked 166 Times in 162 Posts
Default

I went ahead and did up a little example of it below.

================================================== =====

<%@ Page Language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!this.IsPostBack)
        {
            ddlCountries.DataSource = MB.TheBeerHouse.Helpers.GetCountries();
            ddlCountries.DataBind();
        }
    }

    protected void ddlCountries_SelectedIndexChanged(object sender, EventArgs e)
    {
        MembershipUserCollection myUsers = new MembershipUserCollection();
        string searchCountry = ddlCountries.SelectedItem.Text;

        foreach (MembershipUser user in Membership.GetAllUsers())
        {
            ProfileCommon profile = Profile.GetProfile(user.UserName);
            if (profile.Address.Country == searchCountry)
            {
                myUsers.Add(user);
            }
        }

        gvwUsers.DataSource = myUsers;
        gvwUsers.DataBind();
    }

</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Profile Search</title>
</head>
<body>
    <form id="form1" runat="server">
        Choose country:
        <asp:DropDownList ID="ddlCountries" runat="server" AppendDataBoundItems="True" OnSelectedIndexChanged="ddlCountries_SelectedIndex Changed"
            AutoPostBack="True">
            <asp:ListItem Value="" Selected="True">Please select one...</asp:ListItem>
        </asp:DropDownList>
        <asp:GridView ID="gvwUsers" runat="server">
            <EmptyDataTemplate>
                There are no users in that country.
            </EmptyDataTemplate>
        </asp:GridView>
    </form>
</body>
</html>

 
Old April 30th, 2008, 04:55 PM
Authorized User
 
Join Date: Mar 2008
Posts: 62
Thanks: 1
Thanked 3 Times in 3 Posts
Send a message via Yahoo to kalel_4444
Default

ssomchai,

To recap a topic you started: "How i can modify the User profle" http://p2p.wrox.com/topic.asp?TOPIC_ID=69543. A discussion about using the SqlTableProfileProvider was opened up.

Myself, I ended up downloading, installing, and using it. Once I got through a couple of small problems, it has been quite easy to work with. Adding and removing profile fields, and using simple SQL queries in SPROC's against the ProfileTable to select information in it, and then simply dump them into a GridView.

If you use the SqlTableProfileProvider, you'll be able to create queries as simple as:
    
Code:
SELECT * FROM ProfileTable WHERE Country = 'Thailand';

and then drop it into a GridView.

Hope this opens up another alternative,
Ronnie

 
Old April 30th, 2008, 09:07 PM
Authorized User
 
Join Date: Sep 2007
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Default

very Thank everyone

 
Old April 30th, 2008, 09:22 PM
Authorized User
 
Join Date: Sep 2007
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Another question, if i want to send Newletters in group such as group of membership in thailand, or group of gender, or group of occupation, how i can do this?






Similar Threads
Thread Thread Starter Forum Replies Last Post
How to get data from user profiles ssomchai BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 2 May 13th, 2008 01:33 AM
About User Profiles in the beer house ssomchai BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 3 February 25th, 2008 11:28 PM
SELECT de user francofm76 ASP.NET Espanol 2 July 17th, 2006 06:02 PM
Examples of storing user info from db in profiles? bpdsmark ASP.NET 2.0 Basics 0 March 11th, 2006 03:13 PM
Select to all user tables in db Moueg SQL Server 2000 5 December 13th, 2004 10:56 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.