473,473 Members | 1,759 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Issue with DataFormatString...

Roy
Hey all,

Ok, I have a boundcolumn in a datagrid which displays a smalldatetime
field from a table. Behold:

<asp:BoundColumn DataField="final_appvl_dt"
SortExpression="final_appvl_dt" DataFormatString="{0:MMM-dd-yyyy}"
ReadOnly="True" HeaderText="Final Apprvl Date"
ItemStyle-Wrap="false"></asp:BoundColumn>

But the DataFormatString part isn't working as I expect. There's no
error and the date follows the format I specified (i.e., Jan 21 1950),
but the time is still displayed? How can I make the time go away?

Thanks!

Nov 19 '05 #1
9 2814
Hi Roy,

It seems to be working here just fine. Here's the repro code that I used,
including one without format:

<asp:datagrid id="DataGrid1" runat="server"
AutoGenerateColumns="False">
<columns>
<asp:boundcolumn DataField="final_appvl_dt"
SortExpression="final_appvl_dt" DataFormatString="{0:MMM-dd-yyyy}"
ReadOnly="True" HeaderText="Final Apprvl Date"
ItemStyle-Wrap="false"></asp:boundcolumn>
<asp:boundcolumn
DataField="final_appvl_dt" SortExpression="final_appvl_dt"
ReadOnly="True" HeaderText="Final Apprvl Date"
ItemStyle-Wrap="false"></asp:boundcolumn>

</columns>
</asp:datagrid>

Private Sub Page_Load _
(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
If Not IsPostBack Then
DataGrid1.DataSource = CreateDataSource()
DataGrid1.DataBind()
End If
End Sub
Function CreateDataSource() As DataTable
Dim dt As New DataTable
Dim dr As DataRow
dt.Columns.Add(New DataColumn _
("IntegerValue", GetType(Int32)))
dt.Columns.Add(New DataColumn _
("StringValue", GetType(String)))
dt.Columns.Add(New DataColumn _
("CurrencyValue", GetType(Double)))
dt.Columns.Add(New DataColumn _
("Boolean", GetType(Boolean)))
dt.Columns.Add(New DataColumn _
("final_appvl_dt", GetType(DateTime)))
Dim i As Integer
For i = 0 To 4
dr = dt.NewRow()
dr(0) = i
dr(1) = "Item " + i.ToString()
dr(2) = 1.23 * (i + 1)
dr(3) = (i = 4)
dr(4) = Now.AddDays(i)
dt.Rows.Add(dr)
Next i
Return dt
End Function 'CreateDataSource

Ken
Microsoft MVP [ASP.NET]
Toronto

"Roy" <ro**********@gmail.com> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
Hey all,

Ok, I have a boundcolumn in a datagrid which displays a smalldatetime
field from a table. Behold:

<asp:BoundColumn DataField="final_appvl_dt"
SortExpression="final_appvl_dt" DataFormatString="{0:MMM-dd-yyyy}"
ReadOnly="True" HeaderText="Final Apprvl Date"
ItemStyle-Wrap="false"></asp:BoundColumn>

But the DataFormatString part isn't working as I expect. There's no
error and the date follows the format I specified (i.e., Jan 21 1950),
but the time is still displayed? How can I make the time go away?

Thanks!


Nov 19 '05 #2
Roy
Hmmm.

I have no clue what I could be doing wrong then... Cleary it must be
something to do with the code behind page and not my aspx, yet I'm
clueless as to what.

Nov 19 '05 #3
Hi Roy,

If you create another page using just the code that I posted, does it work
for you? Is there something strange in the computer's system date settings?

Ken

"Roy" <ro**********@gmail.com> wrote in message
news:11*********************@f14g2000cwb.googlegro ups.com...
Hmmm.

I have no clue what I could be doing wrong then... Cleary it must be
something to do with the code behind page and not my aspx, yet I'm
clueless as to what.


Nov 19 '05 #4
hi

This should work when that field should be in database as Datetime datatype
or u should return as datatime datatype when u're write a query.

by
gabi(vi********@yahoo.com or vi********@hotmail.com)
"Roy" wrote:
Hey all,

Ok, I have a boundcolumn in a datagrid which displays a smalldatetime
field from a table. Behold:

<asp:BoundColumn DataField="final_appvl_dt"
SortExpression="final_appvl_dt" DataFormatString="{0:MMM-dd-yyyy}"
ReadOnly="True" HeaderText="Final Apprvl Date"
ItemStyle-Wrap="false"></asp:BoundColumn>

But the DataFormatString part isn't working as I expect. There's no
error and the date follows the format I specified (i.e., Jan 21 1950),
but the time is still displayed? How can I make the time go away?

Thanks!

Nov 19 '05 #5
hi

This should work when that field should be in database as Datetime datatype
or u should return as datatime datatype when u're write a query.

by
gabi(vi********@yahoo.com or vi********@hotmail.com)
"Roy" wrote:
Hey all,

Ok, I have a boundcolumn in a datagrid which displays a smalldatetime
field from a table. Behold:

<asp:BoundColumn DataField="final_appvl_dt"
SortExpression="final_appvl_dt" DataFormatString="{0:MMM-dd-yyyy}"
ReadOnly="True" HeaderText="Final Apprvl Date"
ItemStyle-Wrap="false"></asp:BoundColumn>

But the DataFormatString part isn't working as I expect. There's no
error and the date follows the format I specified (i.e., Jan 21 1950),
but the time is still displayed? How can I make the time go away?

Thanks!

Nov 19 '05 #6
hi

This should work when that field should be in database as Datetime datatype
or u should return as datatime datatype when u're write a query.

by
gabi(vi********@yahoo.com or vi********@hotmail.com)
"Roy" wrote:
Hey all,

Ok, I have a boundcolumn in a datagrid which displays a smalldatetime
field from a table. Behold:

<asp:BoundColumn DataField="final_appvl_dt"
SortExpression="final_appvl_dt" DataFormatString="{0:MMM-dd-yyyy}"
ReadOnly="True" HeaderText="Final Apprvl Date"
ItemStyle-Wrap="false"></asp:BoundColumn>

But the DataFormatString part isn't working as I expect. There's no
error and the date follows the format I specified (i.e., Jan 21 1950),
but the time is still displayed? How can I make the time go away?

Thanks!

Nov 19 '05 #7
hi

This should work when that field should be in database as Datetime datatype
or u should return as datatime datatype when u're write a query.

by
gabi(vi********@yahoo.com or vi********@hotmail.com)
"Roy" wrote:
Hey all,

Ok, I have a boundcolumn in a datagrid which displays a smalldatetime
field from a table. Behold:

<asp:BoundColumn DataField="final_appvl_dt"
SortExpression="final_appvl_dt" DataFormatString="{0:MMM-dd-yyyy}"
ReadOnly="True" HeaderText="Final Apprvl Date"
ItemStyle-Wrap="false"></asp:BoundColumn>

But the DataFormatString part isn't working as I expect. There's no
error and the date follows the format I specified (i.e., Jan 21 1950),
but the time is still displayed? How can I make the time go away?

Thanks!

Nov 19 '05 #8
Roy
Hrmm. It does work. This is strange.

Nov 19 '05 #9
Maybe there's a cached version somewhere?

"Roy" <ro**********@gmail.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
Hrmm. It does work. This is strange.


Nov 19 '05 #10

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

Similar topics

1
by: frank | last post by:
I am using the DataFormatString property on BoundColumn objects in a DataGrid, but they don't seem to work for some reason. I copied them straight from another DataGrid where they work fine, but...
0
by: Jordo | last post by:
Help! I have a datagrid that is being populated after a button click to fill based on parameters set by the user at run-time. I am creating the columns programmatically from a datatable and...
3
by: Gerhard Pretorius | last post by:
Since installing the VS.NET August CTP the DataFormatString of the BoundField in the Gridview does not work. Runtime v2.0.50727. <asp:BoundField DataField="Event_Date"...
1
by: Randall Parker | last post by:
In ASP.Net v1.1 and C# suppose one has: protected System.Web.UI.WebControls.DataGrid MyGrid; In Page_Load I want to do the equivalent of: MyGrid.Columns.DataFormatString="{0:d}"; or ...
1
by: Hardy Wang | last post by:
Hi, I have a GridView control in my web form (ASP.NET 2.0) <asp:GridView ID="gvReport" runat="server" AllowSorting="True" AutoGenerateColumns="False" Width="100%"> <HeaderStyle...
2
by: Rob Roberts | last post by:
I have a GridView that is bound to a collection of DateTimes (i.e. - Collection<DateTime>). I have a BoundField in the GridView, and its DataField is set to the DateTime's Date property, and the...
0
by: jobo | last post by:
Hey there, I'm having a problem getting sorting to work. Here's what the GridView looks like: "server" ID="updt1" Mode="Conditional">
0
by: Phillip Ian | last post by:
Tried this over in CSharp.General and didn't get anything, so I thought I'd try again here. If there's an AJAX specific group I could ask this in, please let me know...I did look. I'm trying to...
5
by: Tim Mackey | last post by:
hi, with a derived DataGrid control, i can override the CreateColumnSet method and scan into the DataGridColumns and set the DataFormatString, e.g. leave out the time part of a DateTime value. ...
0
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
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...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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
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
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
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
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.