473,503 Members | 12,791 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Formatting a GridView date?

How does one format a date column in a GridView control? I had assumed that
the DataFormat string would do it, but MSDN only shows numeric formatting
codes. Can dates be formatted using that property, or is it done some other
way?

Thanks in advance.

--
David Veeneman
Foresight Systems
Jan 26 '06 #1
2 2253
I found my answer. The standard date formatting strings work just like the
numeric formatting strings shown in the documentation. The trick is to set
the column's HTMLEncode property to false. The date formatting string is
entered using the same syntax as a numeric formatting string. For example,
{0:d} will give a date a 'short date' format.

--
David Veeneman
Foresight Systems
Jan 26 '06 #2
One point of clarification for anyone else researching this issue: The
HTMLEncode property must be set to false whenever the DataFormatString
property is used, whether for date or numeric data.

--
David Veeneman
Foresight Systems
Jan 26 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1070
by: John Smith | last post by:
Hello, I am a longtime ASP Classic guy, and I am new to .NET. I am hoping someone can help me with what is probably a simple question. I have a stored procedure that returns 5 rows from a...
3
6208
by: washoetech | last post by:
I have a gridview control. In this grid view there is a column for the price of an item. Some of the prices have a dollar sign in front of it and some dont. How do I get rid of the dollar sign...
5
1553
by: Shimon Sim | last post by:
I just don't understand what is wrong. I have simple query. One of the returning fields is data I created bound column for GridView (ASP.NET 2.0) and specified DataFormatString as {0:d} - it...
4
2607
by: Nalaka | last post by:
Hi, I have two questions about gridViews. 1. How can I intercept the row/column values at loading to change values? 2. After I update a row (using default update functionality), how can I...
3
2085
by: Simon Harvey | last post by:
Hi all, I'm having problems getting my date to format. Someone told me that with the GridView, you need to use a TemplateColumn and not a BoundColumn when displaying dates. Given that, can...
2
2690
by: J055 | last post by:
Hi I've been looking into different ways of formatting columns/rows in the GridView control. I realize now, I think, that once the datasource is bound to the control the original column type...
3
2380
by: CSharpguy | last post by:
I'm trying to format the GridView on my web form and its not working. for money I have {0:C} and for date fields, I have {0:d} and the format isn't changing, what else do I need to do to get the...
4
8312
by: Ken Wigle | last post by:
All, I would be very grateful for any help on this question. I have an application in asp.net 2.0 where I dynamically create a datatable and then bind that to a gridview. Unfortunately, the...
12
5923
by: tarscher | last post by:
Hi all, A simple problem that seems hard to solve... I have a gridview with a date row. <ItemTemplate> <asp:Label ID="Label2" runat="server" Text='<%# Bind("time") %>'></asp:Label>...
0
7212
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7098
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7364
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7470
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5604
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
3186
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3174
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1524
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
751
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.