Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Corey Sherman 55 posts 127 karma points
    Oct 08, 2012 @ 15:26
    Corey Sherman
    0

    Programatically Populating Member Properties

    I have a project where I need to use data posted from a custom form to populate member properties using a .NET Web User Control. For the most part, this is pretty straight forward:

    member.getProperty("firstName").Value = !string.IsNullOrEmpty(student.Personal.Name.First) ? student.Personal.Name.First : "";

    The problem I am running into is when I'm trying to set the values for a dropdown list.  I have tried a number of ways to make this work, but to no avail.

    member.getProperty("gender").Value = student.Personal.Gender != Gender.NoneSelected ? EnumExtensions.GetPrevalueId(student.Personal.Gender.ToString()) : 219;

    In the above code, GetPrevalueId is a custom method that returns the Umbraco Prevalue Id for the selected gender.  I have tried this two ways, setting the value to the text string value and to the Id of the prevalue, but when I am saving the Member, I get this error:

    FATAL 10/08/12 12:55:38 [PostStudentProfile:36] umbraco.DataLayer.SqlHelperException Exception Caught in StudentPostMapper.ProcessFormRequest(nvc)!
    FATAL 10/08/12 12:55:38 [PostStudentProfile:37]     Message: Umbraco Exception (DataLayer): SQL helper exception in ExecuteNonQuery
    FATAL 10/08/12 12:55:38 [PostStudentProfile:38]     StackTrace:    at umbraco.DataLayer.SqlHelper`1.ExecuteNonQuery(String commandText, IParameter[] parameters)
       at umbraco.cms.businesslogic.datatype.DefaultData.set_Value(Object value)
       at umbraco.cms.businesslogic.property.Property.set_Value(Object value)
       at code.mappings.StudentPostMapper.UpdateDashboardMembers(Member member, Student student) in code\mappings\StudentPostMapper.cs:line 486
       at code.mappings.StudentPostMapper.ProcessFormRequest(NameValueCollection postedData) in code\mappings\StudentPostMapper.cs:line 63
       at PostStudentProfile.Page_Load(Object sender, EventArgs e) in PostStudentProfile.aspx.cs:line 31

    Also worth noting is that I have tested the value of member.getProperty("gender").Value and it's returning the value that is currently set through the Members panel in Umbraco.

    Can someone point me in the right direction on this one?  I am hoping to avoid creating custom controls as much as possible because there are quite a few dropdowns in the Member Profile...

    Thanks in advance!

Please Sign in or register to post replies

Write your reply to:

Draft