I am using the telerik grid in my ASP.NET MVC3 application and I want to bind the dd / mm / yyyy format date to one of the grid columns, as shown below:
Html.Telerik().Grid<TestResults>()
.Name("TestResultGrid")
.DataKeys(keys => keys.Add(c => c.SourceProgramId))
.Columns(columns =>
{
columns.Bound(c => c.OriginalSourceProgramId).Title("Original Case ID").Width("90").Visible(IsOriginalCaseIdVisible);
columns.Bound(c => c.SourceProgramId).Title("Source Program ID").Width ("90").Visible(!IsOriginalCaseIdVisible);
columns.Bound(c => c.Name).Title("Name").Width("140");
columns.Bound(c => c.Points).Title("Points").Width("50");
columns.Bound(c => c.ProgramName).Title("Program").Width("80");
columns.Bound(c => c.DOB).Title("Created Date").Width("80");
})
.DataBinding(dataBinding =>
dataBinding.Ajax()
.Select("_TestResutls", "Test"))
.ClientEvents(events => events
.OnDataBinding("Grid_onDataBinding")
.OnDataBound("Grid_onDataBound")
.OnRowDataBound("onRowDataBound")
.OnRowSelect("onRowSelected"))
.Pageable(paging => paging.PageSize(10))
.NoRecordsTemplate("<b>No Records to display.<b>")
.Sortable()
.Selectable()
.HtmlAttributes(new { @class = "grid_table" })
.Footer(true)
.Render();
The DOB data type is DateTime ?. I want to show the date format dd / mm / yyyy. I could convert it to ToString () to achieve this, but I have sorting by this column. When I sort by this column, it treats the values as a string and does not return the expected results. This column is NULL, and therefore I cannot use the DOB.Date method. Any help?
source
share