Copied to clipboard

Flag this post as spam?

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


  • Inmedia 124 posts 176 karma points
    Mar 15, 2011 @ 14:44
    Inmedia
    0

    Getting radio button value as text

    Hi everyone

    I have a property called "valgBy", it has a radio button datatype, with multiple choices.

    I need some help on how to display the values as text?

    I know this should be pretty simple for a pro :)

    But I am still a "neewbie" regarding XSLT, so if someone would please help me out? :)

     

    Kind regards

    Mikkel Johansen

  • Kim Andersen 1447 posts 2196 karma points MVP
    Mar 15, 2011 @ 14:47
    Kim Andersen
    0

    Hi Mikkel

    Try this:

    <xsl:value-of select="umbraco.library:GetPreValueAsString($currentPage/valgBy)" />

    /Kim A

  • Inmedia 124 posts 176 karma points
    Mar 15, 2011 @ 14:58
    Inmedia
    0

    No.. I get an error....

    My XSLT looks like this:

     

    <xsl:for-each select="$currentPage/* [@isDoc and string(umbracoNaviHide) != '1']">

        <xsl:value-of select="umbraco.library:GetPreValueAsString($currentPage/valgBy)" />

    </xsl:for-each>

     

    Do you have any idea what could be wrong?

  • Kim Andersen 1447 posts 2196 karma points MVP
    Mar 15, 2011 @ 15:04
    Kim Andersen
    0

    Ahh you are inside a loop.

    Could you try changing it to this then:

    <xsl:for-each select="$currentPage/* [@isDoc and string(umbracoNaviHide) != '1']">

        <xsl:value-of select="umbraco.library:GetPreValueAsString(./valgBy)" />

    </xsl:for-each>

    /Kim A

  • Inmedia 124 posts 176 karma points
    Mar 15, 2011 @ 15:10
    Inmedia
    0

    I still get an error:

     

    Error occured

    System.OverflowException: Value was either too large or too small for an Int32.
    at System.Convert.ToInt32(Double value)
    at System.Double.System.IConvertible.ToInt32(IFormatProvider provider)
    at System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider)
    at System.Xml.Xsl.Runtime.XmlQueryRuntime.ChangeTypeXsltArgument(XmlQueryType xmlType, Object value, Type destinationType)
    at System.Xml.Xsl.Runtime.XmlQueryContext.InvokeXsltLateBoundFunction(String name, String namespaceUri, IList`1[] args)
    at (XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime)
    at Root(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime)
    at Execute(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime)
    at System.Xml.Xsl.XmlILCommand.Execute(Object defaultDocument, XmlResolver dataSources, XsltArgumentList argumentList, XmlSequenceWriter results)
    at System.Xml.Xsl.XmlILCommand.Execute(Object defaultDocument, XmlResolver dataSources, XsltArgumentList argumentList, XmlWriter writer)
    at System.Xml.Xsl.XslCompiledTransform.Transform(IXPathNavigable input, XsltArgumentList arguments, XmlWriter results, XmlResolver documentResolver)
    at System.Xml.Xsl.XslCompiledTransform.Transform(IXPathNavigable input, XsltArgumentList arguments, TextWriter results)
    at umbraco.presentation.webservices.codeEditorSave.SaveXslt(String fileName, String oldName, String fileContents, Boolean ignoreDebugging)

     

    Does this make any sense to you?

  • Kim Andersen 1447 posts 2196 karma points MVP
    Mar 15, 2011 @ 15:12
    Kim Andersen
    0

    Then you probably need to make a test to check that there's actually a vlue in thevalgBy. Like this:

    <xsl:for-each select="$currentPage/* [@isDoc and string(umbracoNaviHide) != '1']">

        <xsl:if test="./valgBy!=''">

            <xsl:value-of select="umbraco.library:GetPreValueAsString(./valgBy)" />

        </xsl:if>

    </xsl:for-each>

    /Kim A

  • Inmedia 124 posts 176 karma points
    Mar 15, 2011 @ 15:17
    Inmedia
    0

    No, that didn't help either... Does it have anything to do with wich version of umbraco I use?

    I am using Umbraco v 4.6.1

  • Kim Andersen 1447 posts 2196 karma points MVP
    Mar 15, 2011 @ 15:19
    Kim Andersen
    0

    Hmm....okay.

    Could you try to print out the current value of the valgBy field? Does this containt an id?

    /Kim A

  • Inmedia 124 posts 176 karma points
    Mar 15, 2011 @ 15:23
    Inmedia
    0

    Oh, I got working now... Apperantly some of the nodes didnt have any of the radiobutton options selected.

    So it seems to work perfectly now... Thank you very much for taking the time to help me out ;)

     

  • Kim Andersen 1447 posts 2196 karma points MVP
    Mar 15, 2011 @ 15:25
    Kim Andersen
    0

    Ahh great to hear Mikkel. I did sound a little weird, so I'm glad it's working now :)

    /Kim A

Please Sign in or register to post replies

Write your reply to:

Draft