Tech Tidbits - Ruby, Ruby On Rails, Merb, .Net, Javascript, jQuery, Ajax, CSS...and other random bits and pieces.

Tuesday, November 6, 2007

Formatting Date Field in Grid View

Due to a bug fix in .NET 2.0, HtmlEncode must be set to False for date formatting to give expected results:


<asp:BoundField DataField="AgendaDate" HeaderText="Agenda Date" SortExpression="AgendaDate" DataFormatString="{0:yyyy-MM-dd}" HtmlEncode=False />


In a Details View using TemplateFields:


<ItemTemplate>
  <asp:Label ID="agendaDateLabel" runat="server" Text='<%# Eval("AgendaDate", "{0:yyyy-MM-dd}") %>'></asp:Label>
</ItemTemplate>

No comments:

About Me

My photo
Developer (Ruby on Rails, iOS), musician/composer, Buddhist, HSP, Vegan, Aspie.

Labels