I have a date column which is in MM/dd/yyyy format. This doesnt sort ascending or descending for all the grids in my application. I am sure what I have done is right. Still it doesnt sort right when I click on header. Please help. One way of doing it is after binding the data source by adding
radgvSixMonthPurchases.Columns[
"transactionDate"].FormatString = "{0:MM/dd/yyyy}";
and othe way is through cell formatting like:
private void radgvSixMonthPurchases_CellFormatting(object sender, Telerik.WinControls.UI.CellFormattingEventArgs e){
if (e.CellElement is GridDataCellElement)
{
Font font = new Font("Tahoma", 6.75F);
e.CellElement.Font = font;
if (((GridViewDataColumn)e.CellElement.ColumnInfo).FieldName == "transactionDate")
{
if (!e.CellElement.Text.StartsWith("0:"))
{
DateTime temp = DateTime.Parse(e.CellElement.Text);
e.CellElement.Text = temp.ToString("MM/dd/yyyy");
}
Font newfont = new Font("Tahoma", 7, FontStyle.Underline);
e.CellElement.Font = newfont;
e.CellElement.ForeColor = Color.Blue;
}
}