473,396 Members | 1,834 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Formatting fields on DataGrid

I have a datagrid on my web form and I have populated it with the following
code:

Dim strConn As String
Dim strSQL As String
strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=D:\Test\MyDatabase.MDB;"

strSQL = "Select client, newstarttime, newendtime, ccode from
EventTable WHERE client <> '' ORDER BY client"
Dim cnn As New OleDbConnection(strConn)
Dim cmd As New OleDbDataAdapter(strSQL, strConn)

Dim ds As New DataSet
cmd.Fill(ds, "EventTable")

DataGrid1.DataSource = ds
DataGrid1.DataBind()

-----------------------------------------------
Question: How can I format the newstarttime and the newendtime fields to
just show time.

in the table, they are defined as Date/Time fields.

Thanks,

Gary

Nov 19 '05 #1
1 1139
You'll need to specify a BoundColumn and then set its DataFormatString, so
something like this:

<asp:BoundColumn DataField="newstarttime" DataFormatString="{0:t}"></asp:BoundColumn>

Here are the docs on the format string for DateTime:

http://msdn.microsoft.com/library/de...asp?frame=true

-Brock
DevelopMentor
http://staff.develop.com/ballen
I have a datagrid on my web form and I have populated it with the
following code:

Dim strConn As String
Dim strSQL As String
strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=D:\Test\MyDatabase.MDB;"
strSQL = "Select client, newstarttime, newendtime, ccode from
EventTable WHERE client <> '' ORDER BY client"
Dim cnn As New OleDbConnection(strConn)
Dim cmd As New OleDbDataAdapter(strSQL, strConn)
Dim ds As New DataSet
cmd.Fill(ds, "EventTable")
DataGrid1.DataSource = ds
DataGrid1.DataBind()
-----------------------------------------------
Question: How can I format the newstarttime and the newendtime fields
to
just show time.
in the table, they are defined as Date/Time fields.

Thanks,

Gary


Nov 19 '05 #2

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

Similar topics

2
by: Sara | last post by:
The problem: Conditional formatting bold, red when field Value < date() sets the field background to white - always - whether condition is met or not. I want the field unfilled and just red/bold...
4
by: deko | last post by:
I've heard it's best not to have any formatting specified for Table fields (except perhaps Currency), and instead set the formatting in the Form or Report. But what about Yes/No fields? When I...
5
by: Jeff Cook | last post by:
Hi I have a DataGrid that I am using to display a .xml file (that has a schema in a .xsd), like this:- ds.ReadXmlSchema(sDataPath + "Data.xsd"); ds.ReadXml(sDataPath + "Data.xml",...
0
by: Josh Harris | last post by:
Here is my issue: I have a datagrid that is populated with a datatable. I want the columns of the datagrid to be sortable. I also want to format the numeric columns such as two decimal places...
7
by: Matthew Wieder | last post by:
Hi - I have a datagrid that has a black header and the rows alternate white and gray. The problem is that until items are added to the grid, the grid appears as a large black rectangle, which is...
4
by: hope | last post by:
Hi, How can I format a string field using Data Formatting Expression property in datagrid? For example: format last name from BROWN to Brown. Thanks
3
by: Jorge Cavalheiro | last post by:
Hello I have a datagrid bound to a dataset which is filled with a table with datetime fields. The datagrid displays them as '26-12-2003' instead of '26- 12-2003 20:00:00'. I've checked the...
1
by: Gary Paris | last post by:
I have a datagrid on my web form and I have populated it with the following code: Dim strConn As String Dim strSQL As String strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data...
3
by: Saladin | last post by:
Hi VB.NET, Desktop app I have an Access table with numeric fields filled mainly with 0 (zeros). When I bind with datagrid, I don't want the zeros to show (ie: I want blank cells). Now I've...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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...

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.