Click here to Skip to main content
15,890,527 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
hello.
I have a column in my table with the name ShowTime and it has time(7) datatype.
I am not allowed to change tht datatype.
the data in this colum is in this format, 13:09:49.5577199
now i want it to be displayed in a dropdownlist like 01:09 PM

how to do it?
Posted
Comments
Abdul Quader Mamun 15-Dec-10 6:46am    
Check spelling & grammar.

Add DataTextFormatString="{0:hh:mm tt}" in DropDownList,
Try this,
<asp:DropDownList ID="DropDownList1" runat="server" DataTextFormatString="{0:hh:mm tt}">
 
Share this answer
 
v2
Comments
rpriyank007 15-Dec-10 5:59am    
where should i write this?
Sandeep Mewara 15-Dec-10 6:20am    
Loop through the items and format the value, add it as item to dropdown
Toniyo Jackson 15-Dec-10 6:30am    
Check the answer now
rpriyank007 15-Dec-10 6:55am    
@ToniyoJackson. i have tried this earlier but its not working.
@sandeep. how should i do that?
Vigneshb6 15-Dec-10 7:02am    
Where u wanna show the time at that point add the DataTextFormatString to DropDown as DropDown.Items.Add(DataTextFormatString);
Hi,

Sample add custom DateTime Formating like as
String.Format("{0:t}", datetime); Output "4:05 PM" .

or
String.Format("{0:T}", datetime); output "4:05:07 PM".

follow this link
DateTime Formating
 
Share this answer
 
v2
Comments
Toniyo Jackson 15-Dec-10 7:14am    
Always write your code inside code block

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900