Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old April 29th, 2008, 09:28 PM
Authorized User
 
Join Date: Sep 2007
Location: , , Thailand.
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

  #2 (permalink)  
Old April 30th, 2008, 11:57 AM
Lee Dumond's Avatar
Wrox Author
Points: 4,942, Level: 29
Points: 4,942, Level: 29 Points: 4,942, Level: 29 Points: 4,942, Level: 29
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2008
Location: Decatur, IL, USA.
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.

  #3 (permalink)  
Old April 30th, 2008, 01:17 PM
Lee Dumond's Avatar
Wrox Author
Points: 4,942, Level: 29
Points: 4,942, Level: 29 Points: 4,942, Level: 29 Points: 4,942, Level: 29
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2008
Location: Decatur, IL, USA.
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>

  #4 (permalink)  
Old April 30th, 2008, 04:55 PM
Authorized User
 
Join Date: Mar 2008
Location: New York, NY, USA.
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

  #5 (permalink)  
Old April 30th, 2008, 09:07 PM
Authorized User
 
Join Date: Sep 2007
Location: , , Thailand.
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Default

very Thank everyone

  #6 (permalink)  
Old April 30th, 2008, 09:22 PM
Authorized User
 
Join Date: Sep 2007
Location: , , Thailand.
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?

 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 02:14 AM.


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