asp DataGrid Format Text Field as DateTime

asp DataGrid Format Text Field as DateTime


Here Im binding to a DataGrid on an asp page, the Database contains a text field that holds a date text on the format "yyyyMMdd" and I want to show the date in the format "day MonthName year",


All I had to do is adding to the Datagrid <Columns> a TemplateColumn with the following binding:


<# DateTime.ParseExact(DataBinder.Eval(Container.DataItem, "DATE_Field").ToString(), "yyyyMMdd", newSystem.Globalization.CultureInfo("ar-sa")).ToString("dd MMM yyyy", newSystem.Globalization.CultureInfo("ar-sa"))%>


For example, lets say the database stores "14350117" in the field DATE_Field as text, the above binding will let it appear as  on the page..



go to link download

Popular posts from this blog

DroidJack RAT Androrat Android Sample

Modern Combat 2 Black Pegasus apk data Free Download

Notepad 6 6 8