List:General Discussion« Previous MessageNext Message »
From:Randall Price Date:December 4 2006 2:39pm
Subject:RE: MySQL Date Issues
View as plain text  
Jesse,

Try the following:

<asp:TemplateColumn>
   <HeaderTemplate><b>Date</b></HeaderTemplate>
   <ItemTemplate>
      <%# DataBinder.Eval(Container.DataItem, " StartDateTime ",
"{0:d}") %>
   </ItemTemplate>
</asp:TemplateColumn>


Hope this helps.

Randall Price

Secure Enterprise Technology Initiatives
Microsoft Implementation Group
Virginia Tech Information Technology
1700 Pratt Drive
Blacksburg, VA  24060

Email:  Randall.Price@stripped
Phone:  (540) 231-4396

-----Original Message-----
From: Price, Randall [mailto:randallp@stripped] 
Sent: Friday, December 01, 2006 5:17 PM
To: Jesse; MySQL List
Subject: RE: MySQL Date Issues

Not sure this is your problem, but do you have the "Allow zero datetime"
option on your connect string?  For example,

connectionString="Server=localhost;
                  User ID=some_user;
                  Password=some_password;
                  Database=some_database;
                  Pooling=false;
                  Allow Zero Datetime=true;"

Thanks,

Randall Price

Secure Enterprise Technology Initiatives
Microsoft Implementation Group
Virginia Tech Information Technology
1700 Pratt Drive
Blacksburg, VA  24060

Email:  Randall.Price@stripped
Phone:  (540) 231-4396

-----Original Message-----
From: Jesse [mailto:jlc@stripped] 
Sent: Friday, December 01, 2006 4:45 PM
To: MySQL List
Subject: MySQL Date Issues

OK, I'm about to pull my hair out with this one.  I know it's simple,
but I 
can't find a way to do this other than switching it to a string and
parsing 
it out manually (something I should have to be forced to do).

I've got a simple MySQL Table with a DateTime field in it.  I want to 
display it as separate fields in a DataGrid, so I've got a column like
this 
in there:

   <asp:TemplateColumn>
      <HeaderTemplate><b>Date</b></HeaderTemplate>
      <ItemTemplate>
         <%# Container.DataItem("StartDateTime") %>
      </ItemTemplate>
   </asp:TemplateColumn>

It displays a blank.

Also, I've got code where the user clicks an Edit link and it brings up
the 
date and time part separately. When I try to run the following code:

   StartDate.Text = FormatDateTime(RS("StartDateTime"),2)
   StartTime.Text = FormatDateTime(RS("StartDateTime"),3)

I get the error, "Cast from type 'MySqlDateTime' to type 'Date' is not 
valid.".  I change change the above code to this:

   StartDate.Text = FormatDateTime(RS("StartDateTime").ToString,2)
   StartTime.Text = FormatDateTime(RS("StartDateTime").ToString,3)

and it works... However, what can I do with the DataGrid column above?

Thanks,
Jesse 


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:
http://lists.mysql.com/mysql?unsub=1


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:
http://lists.mysql.com/mysql?unsub=1

Thread
MySQL Date IssuesJesse1 Dec
  • Can't initialize functionTed Yu1 Dec
  • RE: MySQL Date IssuesRandall Price1 Dec
    • RE: MySQL Date IssuesRandall Price4 Dec
RE: MySQL Date IssuesRandall Price4 Dec