Skip Navigation Links

JosephGuadagno.NET

How do I format my GridView bound column differently?

Sponsors

Side Page Content

Sponsors


Loading...The search is starting ...

Initial Draft

created on 11/5/2007 at 3:04 PM by jguadagno

Number of Views

1385

Description

The answer is simple... Set the DataFormatString property of the BoundField to the desired format and set the HtmlEncode property to false (as outlined below).

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/

<asp :GridView ID=“GridView1″ runat=“server”>
    <columns>
        <asp :BoundField DataField=ColumnName
            DataFormatString={0:M-dd-yyyy}
            HtmlEncode=false
            HeaderText=ColumnName />

        </columns>
</asp:GridView>

Copyright © 2008 Joseph Guadagno. All rights reserved.

About Me - Firefox 2 - Powered By DiscountASP.net Searching is