How do I format my GridView bound column differently?

less than 1 minute read

Replace the ColumnName value with the name of your column. Replace DataFormatString property with the format string of your choosing.  A good reference for .NET string formats is available at http://john-sheehan.com/blog/index.php/net-cheat-sheets/

1
2
3
4
5
6
7
8
<asp:GridView ID="GridView1" runat=“server”>
  <columns>
    <asp:BoundField DataField="ColumnName"
      DataFormatString="{0:M-dd-yyyy}"
      HtmlEncode="false"
      HeaderText="ColumnName" />
  </columns>
</asp:GridView>

Categories:

Updated:

Comments