String was not recognized as a valid DateTime

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Patrick Olurotimi Ige

    String was not recognized as a valid DateTime

    I moved some projects to another server and using the code below i get
    the error:-

    "String was not recognized as a valid DateTime"

    <asp:Label runat="server" width="40%" text='
    <%#
    DateTime.Parse( DataBinder.Eval (Container,"Dat aItem.dt").ToSt ring()).ToSh
    ortDateString() %>' id="Label6">


    *** Sent via Developersdex http://www.developersdex.com ***
  • Patrick Olurotimi Ige

    #2
    Re: String was not recognized as a valid DateTime

    Well folks...
    I added:-
    culture="en-US"
    to the globalization in Web.Config and did the trick

    <globalizatio n
    requestEncoding ="utf-8"
    responseEncodin g="utf-8"
    culture="en-US"
    />



    *** Sent via Developersdex http://www.developersdex.com ***

    Comment

    • Neverlyn

      #3
      RE: String was not recognized as a valid DateTime

      Hi Patrick,

      If you just use DataBinder.Eval (Container,"Dat aItem.dt").ToSt ring() is
      anything displayed?

      If it is, I would be checking that the date format matches your Regional
      Settings (System Account). If you are using SQL I’d also be checking that
      the collation of the new server/database is the same as your old one.

      Brad.


      "Patrick Olurotimi Ige" wrote:
      [color=blue]
      > I moved some projects to another server and using the code below i get
      > the error:-
      >
      > "String was not recognized as a valid DateTime"
      >
      > <asp:Label runat="server" width="40%" text='
      > <%#
      > DateTime.Parse( DataBinder.Eval (Container,"Dat aItem.dt").ToSt ring()).ToSh
      > ortDateString() %>' id="Label6">
      >
      >
      > *** Sent via Developersdex http://www.developersdex.com ***
      >[/color]

      Comment

      • Brock Allen

        #4
        Re: String was not recognized as a valid DateTime

        > <asp:Label runat="server" width="40%" text='[color=blue]
        > <%#
        > DateTime.Parse( DataBinder.Eval (Container,"Dat aItem.dt").ToSt ring()).To
        > Sh
        > ortDateString() %>' id="Label6">[/color]

        Why don't you just do this instead:

        <%# ((DateTime)Data Binder.Eval(Con tainer.DataItem , "dt")).ToShortD ateString()
        %>

        -Brock
        DevelopMentor





        Comment

        Working...