Link to home
Start Free TrialLog in
Avatar of feesu
feesu

asked on

ASP.NET - Formating Date/Time from codebehind

Hi Experts,

I need to display formatted date/time from codebehind, I am doing the following but it doesn't show the proper time:

lblValueDate.Text = Format(CType(DV.Table.Rows(0).Item("ValueDate").ToString, DateTime), "hh:mm tt, dd - MMMM - yyyy")

Although, similar code works fine when assigned from the markup to a grid on the same page:

<asp:Label ID="lblValueDate" runat="server" CssClass="note"
               
                text='<%# "Posted " & Format(DataBinder.Eval(Container, "DataItem.ValueDate"),"hh:mm, dd - MMMM - yyyy") %>'></asp:Label>
        </td>
ASKER CERTIFIED SOLUTION
Avatar of Imran Javed Zia
Imran Javed Zia
Flag of Pakistan image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial