Formatting single row on DataGrid - Webform

G

Gary Paris

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
 
J

johnb41

I haven't worked in web forms in quite a while, but I think i remember
how this is done. I could be wrong, but I think you need to customize
your datagrid.

For example, create separate columns. In the simplest case, make a
bunch of "BoundColumns". BoundColumns have a property called
"DataFormatString". That's the property that you need to format your
date.

Look in your documentation on the syntax for DataFormatString, and then
refer to this link for the details:

http://msdn.microsoft.com/library/d...s/cpguide/html/cpcondatetimeformatstrings.asp

John
 

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

Top