Re: Formatting fields on DataGrid
- From: Brock Allen <ballen@xxxxxxxxxxxxxxxxx>
- Date: Fri, 20 May 2005 10:40:33 -0700
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/default.asp?url=/library/en-us/cpref/html/frlrfsystemdatetimeclasstostringtopic3.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
.
- References:
- Formatting fields on DataGrid
- From: Gary Paris
- Formatting fields on DataGrid
- Prev by Date: Re: Credit Card Processing
- Next by Date: Re: Question about strong-name dlls
- Previous by thread: Formatting fields on DataGrid
- Next by thread: System.Net.WebException: The request failed with the error message:Object moved to here
- Index(es):
Relevant Pages
|