Using Date Format in Eval

ASP.NET Comments Off on Using Date Format in Eval

Hi this is a very simple tip, when you want to Date Format and Use Date Format in Eval, here is the snippet. You all know that Eval or Bind can only be used inside DataControls like Gridview, Repeater, Datalist

Snippet for Using Date Format in Eval

<asp:Label ID="Label1" runat="server" Text='<%#Eval("CreatedDate", "{0:MMMM d, yyyy H:mm tt}")%>'></asp:Label>

The above shows the output as

April 15, 2013 23:46 PM

Obviously, the CreateDate Column from the table should be a Date or DateTime datatype.



Author

Search

Back to Top