Groups | Blog | Home
all groups > asp.net datagrid control > august 2006 >

asp.net datagrid control : DataGrid Date Quandry


stany
8/17/2006 10:58:33 PM
I needed to get a string formatted in to datetime and do a sort on the field. The problem however is that I need the datetime format to be dd MMM yy and also allow a sort on the column. converting the string to date time will do away the formatting; and am getting a longdate format instead. Sticking with the string ("dd MMM yy") would not help me with sorting

See the code below

<asp:TemplateColumn SortExpression="TRANSACTIONDATE" HeaderText="Date"
<ItemTemplate
<%# Convert.ToDateTime(DataBinder.Eval(Container.DataItem,"TRANSACTIONDATE" )).ToString("dd MMM yy") %
</ItemTemplate
</asp:TemplateColumn

Any help on this would be appreciated


---
jyoti
8/18/2006 9:26:42 PM
u can make a component of custom date format by inheriting
System.windows.Forms.DateTimePicker.

Inside InitalizeComponent() make a code like ds.

Format = DateTimePickerFormat.Custom
CustomFormat="dd/mm/yy"

bulid it and refernce this to ur application.
u can directly do ds this code in a form also.







[quoted text, click to view]
AddThis Social Bookmark Button