<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://aspadvice.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Robert Boedigheimer's .NET Blog : Dynamic Data</title><link>http://aspadvice.com/blogs/robertb/archive/tags/Dynamic+Data/default.aspx</link><description>Tags: Dynamic Data</description><dc:language>en</dc:language><generator>CommunityServer 2.1 (Build: 60809.935)</generator><item><title>Dynamic Data DateTime Formatting for Edits</title><link>http://aspadvice.com/blogs/robertb/archive/2008/08/14/Dynamic-Data-DateTime-Formatting-for-Edits.aspx</link><pubDate>Thu, 14 Aug 2008 03:15:00 GMT</pubDate><guid isPermaLink="false">e709ad4c-0c15-48eb-915e-c462c6e85445:45331</guid><dc:creator>robertb</dc:creator><slash:comments>1</slash:comments><comments>http://aspadvice.com/blogs/robertb/comments/45331.aspx</comments><wfw:commentRss>http://aspadvice.com/blogs/robertb/commentrss.aspx?PostID=45331</wfw:commentRss><description>While using the new ASP.NET Dynamic Data, I had a problem when a DateTime field from the database was displaying with the timestamp included.&amp;nbsp; I setup an attribute &lt;font size="2"&gt;&lt;p&gt;[&lt;font size="2" color="#2b91af"&gt;&lt;font size="2" color="#2b91af"&gt;DisplayFormat&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;(DataFormatString=&lt;/font&gt;&lt;font size="2" color="#a31515"&gt;&lt;font size="2" color="#a31515"&gt;&amp;quot;{0:MM/dd/yyyy}&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;)]&lt;/font&gt;&lt;/p&gt;&lt;/font&gt;&lt;p&gt;&lt;font size="2"&gt;on the field and it dropped the timestamp portion when it was in display mode, but when I switched to edit mode it was back...&amp;nbsp; It took quite a few combinations, but I found the proper syntax to use in the DateTime_Edit.ascx to get it to work properly (including when the data from the table is blank).&amp;nbsp; The specifier apparently needed to know it was actually a DateTime, but I ran into conversion issues when the column was empty so this did the trick!&lt;/font&gt;&lt;/p&gt;&lt;font size="2"&gt;&lt;font size="2" color="#0000ff"&gt;&lt;font size="2" color="#0000ff"&gt;&lt;p&gt;&amp;lt;&lt;font size="2" color="#a31515"&gt;&lt;font size="2" color="#a31515"&gt;asp&lt;/font&gt;&lt;/font&gt;&lt;font size="2" color="#0000ff"&gt;&lt;font size="2" color="#0000ff"&gt;:&lt;/font&gt;&lt;/font&gt;&lt;font size="2" color="#a31515"&gt;&lt;font size="2" color="#a31515"&gt;TextBox&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;font size="2" color="#ff0000"&gt;&lt;font size="2" color="#ff0000"&gt;ID&lt;/font&gt;&lt;/font&gt;&lt;font size="2" color="#0000ff"&gt;&lt;font size="2" color="#0000ff"&gt;=&amp;quot;TextBox1&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;font size="2" color="#ff0000"&gt;&lt;font size="2" color="#ff0000"&gt;runat&lt;/font&gt;&lt;/font&gt;&lt;font size="2" color="#0000ff"&gt;&lt;font size="2" color="#0000ff"&gt;=&amp;quot;server&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;font size="2" color="#ff0000"&gt;&lt;font size="2" color="#ff0000"&gt;CssClass&lt;/font&gt;&lt;/font&gt;&lt;font size="2" color="#0000ff"&gt;&lt;font size="2" color="#0000ff"&gt;=&amp;quot;droplist&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;font size="2" color="#ff0000"&gt;&lt;font size="2" color="#ff0000"&gt;Text&lt;/font&gt;&lt;/font&gt;&lt;font size="2" color="#0000ff"&gt;&lt;font size="2" color="#0000ff"&gt;=&amp;#39;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;&amp;lt;%# (FieldValueEditString != &amp;quot;&amp;quot;) ? String.Format(&amp;quot;{0:MM/dd/yyyy}&amp;quot;,Convert.ToDateTime(FieldValueEditString)) : &amp;quot;&amp;quot; %&amp;gt;&lt;/font&gt;&lt;font size="2" color="#0000ff"&gt;&lt;font size="2" color="#0000ff"&gt;&amp;#39;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;font size="2" color="#ff0000"&gt;&lt;font size="2" color="#ff0000"&gt;Columns&lt;/font&gt;&lt;/font&gt;&lt;font size="2" color="#0000ff"&gt;&lt;font size="2" color="#0000ff"&gt;=&amp;quot;20&amp;quot;&amp;gt;&amp;lt;/&lt;/font&gt;&lt;/font&gt;&lt;font size="2" color="#a31515"&gt;&lt;font size="2" color="#a31515"&gt;asp&lt;/font&gt;&lt;/font&gt;&lt;font size="2" color="#0000ff"&gt;&lt;font size="2" color="#0000ff"&gt;:&lt;/font&gt;&lt;/font&gt;&lt;font size="2" color="#a31515"&gt;&lt;font size="2" color="#a31515"&gt;TextBox&lt;/font&gt;&lt;/font&gt;&lt;font size="2" color="#0000ff"&gt;&lt;font size="2" color="#0000ff"&gt;&amp;gt;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;
&lt;div class = "shareblock"&gt;&lt;strong&gt;Share this post:&lt;/strong&gt; &lt;a href = "mailto:?body=Thought you might like this: http://aspadvice.com/blogs/robertb/archive/2008/08/14/Dynamic-Data-DateTime-Formatting-for-Edits.aspx&amp;amp;;subject=Dynamic+Data+DateTime+Formatting+for+Edits" target="_blank" title = "Post http://aspadvice.com/blogs/robertb/archive/2008/08/14/Dynamic-Data-DateTime-Formatting-for-Edits.aspx"&gt;email it!&lt;/a&gt; |  &lt;a href = "http://del.icio.us/post?url=http://aspadvice.com/blogs/robertb/archive/2008/08/14/Dynamic-Data-DateTime-Formatting-for-Edits.aspx&amp;amp;;title=Dynamic+Data+DateTime+Formatting+for+Edits" target="_blank" title = "Post http://aspadvice.com/blogs/robertb/archive/2008/08/14/Dynamic-Data-DateTime-Formatting-for-Edits.aspx"&gt;bookmark it!&lt;/a&gt; |  &lt;a href = "http://www.digg.com/submit?url=http://aspadvice.com/blogs/robertb/archive/2008/08/14/Dynamic-Data-DateTime-Formatting-for-Edits.aspx&amp;amp;;phase=2" target="_blank" title = "Post http://aspadvice.com/blogs/robertb/archive/2008/08/14/Dynamic-Data-DateTime-Formatting-for-Edits.aspx"&gt;digg it!&lt;/a&gt; |  &lt;a href = "http://reddit.com/submit?url=http://aspadvice.com/blogs/robertb/archive/2008/08/14/Dynamic-Data-DateTime-Formatting-for-Edits.aspx&amp;amp;title=Dynamic+Data+DateTime+Formatting+for+Edits" target="_blank" title = "Post http://aspadvice.com/blogs/robertb/archive/2008/08/14/Dynamic-Data-DateTime-Formatting-for-Edits.aspx"&gt;reddit!&lt;/a&gt; |  &lt;a href = "http://www.dotnetkicks.com/submit/?url=http://aspadvice.com/blogs/robertb/archive/2008/08/14/Dynamic-Data-DateTime-Formatting-for-Edits.aspx&amp;amp;;title=Dynamic+Data+DateTime+Formatting+for+Edits" target="_blank" title = "Post http://aspadvice.com/blogs/robertb/archive/2008/08/14/Dynamic-Data-DateTime-Formatting-for-Edits.aspx"&gt;kick it!&lt;/a&gt; |  &lt;a href = "https://favorites.live.com/quickadd.aspx?marklet=1&amp;amp;;mkt=en-us&amp;amp;;url=http://aspadvice.com/blogs/robertb/archive/2008/08/14/Dynamic-Data-DateTime-Formatting-for-Edits.aspx&amp;amp;;title=Dynamic+Data+DateTime+Formatting+for+Edits&amp;amp;;top=1" target="_blank" title = "Post http://aspadvice.com/blogs/robertb/archive/2008/08/14/Dynamic-Data-DateTime-Formatting-for-Edits.aspx"&gt;live it!&lt;/a&gt;&lt;/div&gt;&lt;img src="http://aspadvice.com/aggbug.aspx?PostID=45331" width="1" height="1"&gt;</description><category domain="http://aspadvice.com/blogs/robertb/archive/tags/Dynamic+Data/default.aspx">Dynamic Data</category></item></channel></rss>