Formatting datetime in databinded XML

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • gurufordy
    New Member
    • Aug 2008
    • 14

    Formatting datetime in databinded XML

    Hey guys. I have got a load of XML that I serialised from a class. I am databinding this to a Repeater and letting it do it's magic. My problem is that one of the fields is a date and so I need to format it properly. I am having no luck so can anyone help?

    XML:

    Code:
    <SimpleList xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <Summary>
    <ID>9</ID>
    <Inserted>2008-09-29T09:35:17.663</Inserted>
    <LastUpdated>1900-01-01T00:00:06.837</LastUpdated>
    </Summary>
    </SimpleList>
    ASPX Code for databind:

    Code:
    <%#(Ctype(Container.DataItem, System.Xml.XmlNode))("ID").InnerText %>
    <%#(Ctype(Container.DataItem, System.Xml.XmlNode))("Inserted").InnerText %>
    I obviously want the 'Inserted' element to be like dd/MM/yyyy or something similar.
  • JamieHowarth0
    Recognized Expert Contributor
    • May 2007
    • 537

    #2
    Hi there,

    You want to try this:
    Code:
    <%# Format((Ctype(Container.DataItem, System.Xml.XmlNode))("Inserted").InnerText, "mm/dd/yyyy") %>
    Hope it helps.

    codegecko

    Comment

    • gurufordy
      New Member
      • Aug 2008
      • 14

      #3
      Originally posted by codegecko
      Hi there,

      You want to try this:
      Code:
      <%# Format((Ctype(Container.DataItem, System.Xml.XmlNode))("Inserted").InnerText, "mm/dd/yyyy") %>
      Hope it helps.

      codegecko
      Sorry for the deleayed reply mate. Been a very busy week. I am pretty sure I tried this but it just outputs "mm/dd/yyyy" instead of the formatted string. I will give it another try and report back though as I may be wrong :)

      Comment

      • gurufordy
        New Member
        • Aug 2008
        • 14

        #4
        Yeah it's as I thought. It comes back with just 'mm/dd/yyyy' instead of a formatted date.

        Any other help mate?

        Comment

        • gurufordy
          New Member
          • Aug 2008
          • 14

          #5
          Bumpty bumpty bump :)

          Comment

          Working...