Great, So I got a chance this morning to implement this code. Im using visual web developer 2008. It seems like this code is written in a slight variation of the family of the microsoft programming lannguages... but i tried to rewrite it so it would work
on VWD 2008.
So far I have
If (e.Row.RowType = DataControlRowType.DataRow) Then .....
What does DateTime dTime; mean? is dtime being declared as a data type of DateTime ? so id write is as dim dtime as datetime or what does it stand for?
Thanks
vinz
Place it under RowDataBound event of GridView since you are displaying your data in GridView.. Also i have some modifacation about my last post.. so try this below instead
Great, So I got a chance this morning to implement this code. Im using visual web developer 2008. It seems like this code is written in a slight variation of the family of the microsoft programming lannguages... but i tried to rewrite it so it would work on
VWD 2008.
Basically the codes that I have provided was written in C#..So here's the VB.NET equivalent below
Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As GridViewRowEventArgs)
If e.Row.RowType = DataControlRowType.DataRow Then
Dim dTime As DateTime
If DateTime.TryParse(e.Row.Cells(0).Text.Trim(), dTime) Then 'Just change the index of Cells to where your Time is being displayed in the GridView columns
e.Row.Cells(0).Text = dTime.ToString("h:mm tt")
End If
End If
End Sub
Sweet, this works very well. ;) Thank you very much.
Has given me insight on what one can do on the rowdatabound event.
Also after a little more reading on the 'time' data type, one can use it to store time length, say 54 hours 20 minutes.... so Im thinking this may not be appropriate for my application.
I should just use the datetime field, which would than make formating pretty easy. (My web application is a meeting room bookings. So it has room name, start date, start time and end time and a few other fields) So you see i was using start time and end
time as time fields....
Thanks again! :)
vinz
Basically the codes that I have provided was written in C#..So here's the VB.NET equivalent below
Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As GridViewRowEventArgs)
If e.Row.RowType = DataControlRowType.DataRow Then
Dim dTime As DateTime
If DateTime.TryParse(e.Row.Cells(0).Text.Trim(), dTime) Then 'Just change the index of Cells to where your Time is being displayed in the GridView columns
e.Row.Cells(0).Text = dTime.ToString("h:mm tt")
End If
End If
End Sub
parthrawal
Member
432 Points
535 Posts
Re: how to format a mysql time field to show as am or pm?
Jul 16, 2008 04:39 AM|LINK
Sorry, Here While writing for the post i forget that this is CASE Sensitive..............Really Sorry to misleading info.
And really i am not taking this as an wrong thing, Sorry If these words feel Harsh.............[:P]
Parth
visit for some interesting articals at
www.parthrawal.blogspot.com
Mark as Answer if it helps you
roi8877
0 Points
13 Posts
Re: how to format a mysql time field to show as am or pm?
Jul 16, 2008 04:30 PM|LINK
Great, So I got a chance this morning to implement this code. Im using visual web developer 2008. It seems like this code is written in a slight variation of the family of the microsoft programming lannguages... but i tried to rewrite it so it would work on VWD 2008.
So far I have
If (e.Row.RowType = DataControlRowType.DataRow) Then .....
What does DateTime dTime; mean? is dtime being declared as a data type of DateTime ? so id write is as dim dtime as datetime or what does it stand for?
Thanks
vinz
All-Star
116078 Points
16314 Posts
MVP
Re: how to format a mysql time field to show as am or pm?
Jul 17, 2008 01:29 AM|LINK
Basically the codes that I have provided was written in C#..So here's the VB.NET equivalent below
Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As GridViewRowEventArgs)
If e.Row.RowType = DataControlRowType.DataRow Then
Dim dTime As DateTime
If DateTime.TryParse(e.Row.Cells(0).Text.Trim(), dTime) Then 'Just change the index of Cells to where your Time is being displayed in the GridView columns
e.Row.Cells(0).Text = dTime.ToString("h:mm tt")
End If
End If
End Sub
MessageBox Controls for WebForms |Blog
roi8877
0 Points
13 Posts
Re: how to format a mysql time field to show as am or pm?
Jul 18, 2008 06:43 PM|LINK
Sweet, this works very well. ;) Thank you very much.
Has given me insight on what one can do on the rowdatabound event.
Also after a little more reading on the 'time' data type, one can use it to store time length, say 54 hours 20 minutes.... so Im thinking this may not be appropriate for my application.
I should just use the datetime field, which would than make formating pretty easy. (My web application is a meeting room bookings. So it has room name, start date, start time and end time and a few other fields) So you see i was using start time and end time as time fields....
Thanks again! :)
InterfaceMirror
Member
147 Points
48 Posts
Re: how to format a mysql time field to show as am or pm?
Aug 04, 2008 07:15 AM|LINK
Thanks,
It is a very useful post.