DataFormatString in GridView has no affect on column formatting

P

pgonzo

In my initial tests with the GridView control, I cannot understand why
the DataFormatString attribute has no affect on the column formatting.
The 'creation_date' field is being reported as "3/30/02 14:23:28". I
want to
display it as "03/30/02".

I've included the code below. Can anyone offer an explanation?


<asp:SqlDataSource ID="DD_Issues" runat="server"
ConnectionString="<%$ ConnectionStrings:AMGConnectionString %>">
</asp:SqlDataSource>

<asp:GridView ID="GridView1" runat="server"
AutoGenerateColumns="False" DataSourceID="DD_Issues" AllowPaging="True"
CellPadding="4" ForeColor="#333333" GridLines="None" >
<Columns>
<asp:BoundField DataField="issue_id"
HeaderText="issue_id" InsertVisible="False"
ReadOnly="True" SortExpression="issue_id" />
<asp:BoundField DataField="issue_description"
HeaderText="Issue Description" SortExpression="issue_description" />
<asp:BoundField DataField="creation_date"
HeaderText="creation_date" SortExpression="creation_date"
DataFormatString="{0:MM/dd/yy}" />
</Columns>
</asp:GridView>
 
P

pgonzo

Worked like a charm! Thank you very much.

Set HtmlEncode = false for the column.

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]http://msmvps.com/blogs/egoldin



In my initial tests with the GridView control, I cannot understand why
the DataFormatString attribute has no affect on the column formatting.
The 'creation_date' field is being reported as "3/30/02 14:23:28". I
want to
display it as "03/30/02".
I've included the code below. Can anyone offer an explanation?
<asp:SqlDataSource ID="DD_Issues" runat="server"
ConnectionString="<%$ ConnectionStrings:AMGConnectionString %>">
</asp:SqlDataSource>
<asp:GridView ID="GridView1" runat="server"
AutoGenerateColumns="False" DataSourceID="DD_Issues" AllowPaging="True"
CellPadding="4" ForeColor="#333333" GridLines="None" >
<Columns>
<asp:BoundField DataField="issue_id"
HeaderText="issue_id" InsertVisible="False"
ReadOnly="True" SortExpression="issue_id" />
<asp:BoundField DataField="issue_description"
HeaderText="Issue Description" SortExpression="issue_description" />
<asp:BoundField DataField="creation_date"
HeaderText="creation_date" SortExpression="creation_date"
DataFormatString="{0:MM/dd/yy}" />
</Columns>
</asp:GridView>- Hide quoted text -- Show quoted text -
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,836
Messages
2,569,748
Members
45,545
Latest member
rapter____0

Latest Threads

Top