Copied to clipboard

Flag this post as spam?

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


  • David Hammer 41 posts 67 karma points
    Jan 17, 2014 @ 14:55
    David Hammer
    0

    Parsing NodeId as text to int

    Hey guys!

    I'm currently making it possible for people to import xml files into via import in the content section in umbraco.. for that I've created a user control.

    Now my problem is this:

    I'm looking to parse the NodeId to int:

    if (!string.IsNullOrEmpty(NodeId.Text.ToString()))
    {
        parrentNodeid = int.Parse(String NodeId.Text);
    }
    

    But this results in the following errors: [FormatException: Input string was not in a correct format.]

    Can you tell me what is not the correct format and how I should do it differently? Would be a big help!!

  • Jeroen Breuer 4908 posts 12265 karma points MVP 5x admin c-trib
    Jan 19, 2014 @ 11:23
    Jeroen Breuer
    0

    Have a look at this SO question: http://stackoverflow.com/questions/8321514/input-string-was-not-in-a-correct-format#8321527

    There probably is a value which you can't convert to an int. Maybe there is a corrupt value in the import file. Try using int.TryParse.

    Jeroen

     

Please Sign in or register to post replies

Write your reply to:

Draft