Copied to clipboard

Flag this post as spam?

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


  • Bo Kingo Damgaard 157 posts 456 karma points
    Apr 20, 2011 @ 19:50
    Bo Kingo Damgaard
    0

    How to handle other types than string i Member profiles

    Hi

    I've created a custom Profilebase, by following Aaron Powels excellent blogpost here http://www.aaron-powell.com/umbraco-members-profiles. I can't get to handle undefined datatypes other than strings. From Aaron's post I test for an undefined string by testing like this:

    if (o == DBNull.Value)
    {
    return string.Empty;
    }

    I can't seem to test for undefined Boolean or DateTime type this way. I have tried like this:

    if (o == null)
    {
    return false)
    }
    return ((int)0 == 1);

    But it doesn't catch it, and then fails when casting to int

    How do I test for undefined Boolean and DateTime?

    /Bo Kingo

  • Bo Kingo Damgaard 157 posts 456 karma points
    Apr 20, 2011 @ 19:55
    Bo Kingo Damgaard
    0

    And by the way, I run on MS SQL CE - could that be related? I've seen problems with CE in the forum before.

     

  • Bo Kingo Damgaard 157 posts 456 karma points
    Apr 21, 2011 @ 09:53
    Bo Kingo Damgaard
    0

    To answer my own question: It seems that the object returned is a string when undefined, so I fixed it by doing this:

                    if (o is string)
    {
    // Undefined boolean
    return false;
    }
    return ((int)o == 1);

    That seems to work and for DateTime too.

Please Sign in or register to post replies

Write your reply to:

Draft