private int _id; private DateTime _ClosingDate; public DateTime ClosingDate { get { return _ClosingDate; } set { _ClosingDate = value; } } private List<PotentialEntity> fetchrecords(DataTable FTable) { List<PotentialEntity> Entity = new List<PotentialEntity>(); foreach (DataRow oRow in FTable.Rows) { PotentialEntity pEntity = new PotentialEntity(); pEntity.ClosingDate =(DateTime)(oRow["ClosingDate"]); Entity.Add(pEntity); } return Entity; } GridView1.DataSource = Entity; GridView1.DataBind()
<asp:TemplateField HeaderStyle-Width="100px" HeaderStyle-ForeColor="White" meta:resourcekey="TemplateFieldResource5"> <itemtemplate> <asp:Label ID="lblClosingDate" runat="server" Text='<%# Eval("ClosingDate").ToString().Substring(0,10) %>' meta:resourcekey="lblClosingDateResource1"/></itemtemplate> <HeaderStyle Width="100px" />
Parse
TryParse
string Date="28/12/2013"; DateTime Dt = DateTime.Now(); DateTime.TryParse(string,out Dt);
string value = oRow["ClosingDate"] + ""; // keep a break point and check the value, in which format the value appears // based on the format you can change the format value string format = "MM/dd/yyyy"; var datetime = DateTime.ParseExact(value,format,System.Globalization.CultureInfo.InvariantCulture );
((DateTime)(oRow["ClosingDate"])).ToString("dd/MM/yyyy")
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)