Copied to clipboard

Flag this post as spam?

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


  • Siw Ørnhaug 130 posts 109 karma points
    Sep 13, 2011 @ 21:55
    Siw Ørnhaug
    0

    Custom datatype and value is not saved (again)

    I've browsed through loads of posts on more or less my type of problem, but I'm unable to find the exact solution to my problem.

    I based my datatype on the http://www.nibble.be/?p=24 example. It's a listbox with static list items, which triggers some other controls in it's selectedindexchanged event. That's also where I set the umbracoValue to selected listeitem. 

    I've registered  the datatype as database datatype nvarchar, and I run my datatype without problems, but the value I hope to assign is not saved to the database/xml data.

    When I run my usercontrol from VS2010 the umbraco value is both got and set.
    My code (the interesting part of it):

     

     

    public string umbracoValue;

     

     

    public object value

    {

     

     

    get

    {

     

     

    return umbracoValue;

    }

     

     

    set

    {

    umbracoValue =

     

    value.ToString();

    }

    }

     

     

    protected void Page_Load(object sender, EventArgs e)

    {

     

     

    if (!Page.IsPostBack)

    {

     

     

    if (umbracoValue != null)

    {

     

     

    if (umbracoValue.ToString() != "")

    {

    lbTemplates.SelectedValue = umbracoValue.ToString();

    mvTemplates.ActiveViewIndex = lbTemplates.SelectedIndex;

    lblTemplateDescription.Text = getDescription(lbTemplates.SelectedIndex);

    }

     

     

    else

    {

    umbracoValue =

     

    "template1";

    lbTemplates.SelectedIndex = 0;

    mvTemplates.ActiveViewIndex = 0;

    lblTemplateDescription.Text = getDescription(0);

    }

    }

     

     

    else

    {

    umbracoValue =

     

    "template1";

    lbTemplates.SelectedIndex = 0;

    mvTemplates.ActiveViewIndex = 0;

    lblTemplateDescription.Text = getDescription(0);

    }

    }

    }

     

     

    protected void lbTemplates_SelectedIndexChanged(object sender, EventArgs e)

    {

    mvTemplates.ActiveViewIndex = lbTemplates.SelectedIndex;

    lblTemplateDescription.Text = getDescription(lbTemplates.SelectedIndex);

    umbracoValue = lbTemplates.SelectedValue;

    }

     

  • Siw Ørnhaug 130 posts 109 karma points
    Sep 14, 2011 @ 13:07
    Siw Ørnhaug
    0

    So it's solved. Watching Tims video on custom datatypes with usercontrol wrapper enlightened me. Ditching the string umbracValue from his blog code and connecting the value object directly with the control with the value I wanted stored made all the difference to me ;-)

Please Sign in or register to post replies

Write your reply to:

Draft