Hey. I have created a website that uses aspnetdb. Using this, i'm trying to take advantage of the profile table. I have it working and I can pull info from the logged in user and display it on the page, however, when i try and load the info on another page and get it to update, it will not update. Can you please help. Thx!!!

Web Config file

<profile enabled="true" automaticSaveEnabled="true">
			<providers>
			</providers>
			<properties>
				<add name="RecordNumber" type="Int32"/>
				<add name="Prefix" type="string"/>
				<add name="FirstName" type="string"/>
				<add name="MiddleName" type="string"/>
				<add name="LastName" type="string"/>
				<add name="Suffix" type="string"/>
				<add name="BrotherType" type="string"/>
				<add name="Address1" type="string"/>
				<add name="Address2" type="string"/>
				<add name="Address3" type="string"/>
				<add name="city" type="string"/>
				<add name="state" type="string"/>
				<add name="postalCode"/>
				<add name="PrimaryEmail" type="string"/>
				<add name="SecondaryEmail" type="string"/>
				<add name="PhoneNumber" type="string"/>
				<add name="CellPhoneNumber" type="string"/>
				<add name="CellPhoneProvider" type="string"/>
				<add name="InitiationDate" type="Date"/>
				<add name="PledgeDate" type="Date"/>
				<add name="BirthDate" type="Date"/>
				<add name="ProfileImage" type="string"/>
			</properties>
		</profile>

Profile.aspx.cs (Displays Properly)

using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.Profile;

public partial class Users_Profile : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        //Load Profile Image and If it isn't a available, then it will load the default automatically.
        if (Profile.ProfileImage == null)
            profileImage.Visible = false;
        else
            profileImage.ImageUrl = "~/BrotherImages/default.jpg";

        //Create some datetime variables to Convert to short date
        DateTime bdate = new DateTime();
        DateTime idate = new DateTime();
        DateTime pdate = new DateTime();

        bdate = Profile.BirthDate;
        pdate = Profile.PledgeDate;
        idate = Profile.InitiationDate;
        

        //Create Variable to calculate Age 
        int age = new DateTime(DateTime.Now.Subtract(bdate).Ticks).Year - 1;



        lblName.Text = Profile.FirstName + " " + Profile.LastName;
        lblAge.Text = age.ToString();
        lblBrotherType.Text = Profile.BrotherType;
        lblEmail.Text = "Bind Data from table";
        lblPhone.Text = Profile.PhoneNumber;
        lblCell.Text = Profile.CellPhoneNumber;
        lblRecordNumber.Text = Convert.ToString(Profile.RecordNumber);
        lblBirthDate.Text = bdate.ToString("d");
        lblInitiationDate.Text = idate.ToString("d");
        lblPledgeDate.Text = pdate.ToString("d");
        lblAddress1.Text = Profile.Address1;
        lblAddress2.Text = Profile.Address2;
        lblAddress3.Text = Profile.Address3;
        lblCity.Text = Profile.city;
        lblState.Text = Profile.state;
        lblZipCode.Text = Profile.postalCode;

    }
    protected void lblUpdateProfile_Click(object sender, EventArgs e)
    {

    }
}

UpdateProfile.aspx.cs

using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;


public partial class Users_UpdateProfile : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!this.IsPostBack)
        {
            //Load default data for the drop down list dates.

            //Load Birthdate Info
            for (int i = 1; i <= 12; i++)
            {
                ddlBirthDateMonth.Items.Add(i.ToString());
            }
            for (int x = 1; x <= 31; x++)
            {
                ddlBirthDateDay.Items.Add(x.ToString());
            }
            int byear = System.DateTime.Now.Year;
            for (int y = 95; y > 1; y--)
            {
                byear = byear - 1;
                ddlBirthDateYear.Items.Add(byear.ToString());
            }
            //Load Initiation Date Info

            for (int i = 1; i <= 12; i++)
            {
                ddlIDateMonth.Items.Add(i.ToString());
            }
            for (int x = 1; x <= 31; x++)
            {
                ddlIDateDay.Items.Add(x.ToString());
            }
            int iyear = System.DateTime.Now.Year;
            for (int y = 95; y > 1; y--)
            {
                iyear = iyear - 1;
                ddlIDateYear.Items.Add(iyear.ToString());

            }
            //Load Items for the drop down list for pledge dates
            for (int i = 1; i <= 12; i++)
            {
                ddlPDateMonth.Items.Add(i.ToString());
            }
            for (int x = 1; x <= 31; x++)
            {
                ddlPDateDay.Items.Add(x.ToString());
            }
            int pyear = System.DateTime.Now.Year;
            for (int y = 95; y > 1; y--)
            {
                pyear = pyear - 1;
                ddlPDateYear.Items.Add(pyear.ToString());
            }

            //load text boxes with profile data
            txtPrefix.Text = Profile.Prefix;
            txtFName.Text = Profile.FirstName;
            txtMName.Text = Profile.MiddleName;
            txtLName.Text = Profile.LastName;
            txtSuffix.Text = Profile.Suffix;
            txtBrotherType.Text = Profile.BrotherType;
            txtAdd1.Text = Profile.Address1;
            txtAdd2.Text = Profile.Address2;
            txtAdd3.Text = Profile.Address3;
            txtCity.Text = Profile.city;
            txtState.Text = Profile.state;
            txtPEmail.Text = "Working on this currently";
            txtSEmail.Text = Profile.SecondaryEmail;

            //Work on loading phone and cell phone for later use. However right now it will be blank by default.
            txtPAreaCode.Text = "";
            txtPCountyCode.Text = "";
            txtPDigitCode.Text = "";
            txtCAreaCode.Text = "";
            txtCCountyCode.Text = "";
            txtCDigitCode.Text = "";
        }
    }
    protected void btnSaveProfile_Click(object sender, EventArgs e)
    {
        ProfileCommon p = Profile.GetProfile();
        p.Prefix = txtPrefix.Text;
        p.Suffix = txtSuffix.Text;
        p.FirstName = txtFName.Text;
        p.MiddleName = txtMName.Text;
        p.LastName = txtLName.Text;
        p.Address1 = txtAdd1.Text;
        p.Address2 = txtAdd2.Text;
        p.Address3 = txtAdd3.Text;
        p.city = txtCity.Text;
        p.state = txtState.Text;
        p.postalCode = txtZipCode.Text;
        p.SecondaryEmail = txtSEmail.Text;
        p.PhoneNumber = "(" + txtPAreaCode.Text + ") " + txtPCountyCode.Text + "-" + txtPDigitCode.Text;
        //Add Cell Phone property in here if you wish.

        p.BirthDate =Convert.ToDateTime(ddlBirthDateMonth.SelectedItem.ToString() + "/" + ddlBirthDateDay.SelectedItem.ToString() + "/" + ddlBirthDateYear.SelectedItem.ToString());
        p.Save();
    }
}

My guess is its because it cant find the userid or the username. I'm just not sure how to pass or load/save the info.

Do use Profile page object.

Profile.Prefix = txtPrefix.Text;
.....

I figured out what was wrong with it! it wasn't my code, it was cuz the update button had a redirect url... when i needed to add the redirect after my code. Took me a while to figure that out but i got it. thanks for your reply.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.