Retrieve back custom data type from logged-in user to the page for editing
I am trying to get saved member profile data back from Umbraco CMS. In Umbraco there is custom data types. I created one suitable for dropdownlist and used it during registration process. After a user is created and logged-in, user should be able to update or change its profile information in profile page. During registration process I grab dropdownlist custom data type like in the following but I stuck at the point how to retrieve back that data along with user selection to the user profile page for editing.
The code snippet for grabbing custom data for dropdownlist during registration.
DropDownList ddlSector = (DropDownList)CreateUserWizardStep0.FindControl("Sector");
XPathNodeIterator pvDdlSector = umbraco.library.GetPreValues(1206);
pvDdlSector.M开发者_JS百科oveNext();
XPathNodeIterator pvValuesDdlSector = pvDdlSector.Current.SelectChildren("preValue", "");
while (pvValuesDdlSector.MoveNext())
{
ddlSector.Items.Add(new ListItem(pvValuesDdlSector.Current.Value, pvValuesDdlSector.Current.GetAttribute("id", "")));
}
The code snippet on Created User event for saving user
MemberProfile mp = MemberProfile.GetUserProfile(cuw.UserName);
DropDownList ddlSector = (DropDownList)CreateUserWizardStep0.FindControl("Sector");
string lbSectorValue = "";
foreach (ListItem item in ddlSector.Items)
if (item.Selected) lbSectorValue += (lbSectorValue == "" ? "" : ",") + item.Value;
mp.Sector = lbSectorValue;
Any help much appreciated
Here is a an excellent post on how to work with custom Umbraco profile data.
http://www.aaron-powell.com/umbraco-members-profiles
Basically you need to do a bit of wiring up to enable easy access to the custom profile properties. The approach shown is two way so it will also allow you to write back to umbraco as well.
Tim
精彩评论