Hello everybody,
My question is simple, but please keep in mind that I am not binding it to any grid or to any ASP.NET control. I have my own grid control and I want to save it as a DateTime column for sorting.
I am creating a DataTable with a DateTime type of a column type.
DataTable data = new DataTable(); data.Columns.Add("Invoice Date", typeof(DateTime)); DataRow dr = data.NewRow(); dr[0] = DateTime.Now; //Adding filled row to the DataTable object dataTable.Rows.Add(dr);
When a value is displayed on an ASP.NET page, it displays something like this:
"2/28/2011 12:00:00 AM"
I have 2 columns like this. In column 1, I want to show only the date, and in another column I want to show the date as "December 2011", these formats can be achieved if I use a DataColumn with a type string, but in this case the sorting does not work properly.
Please, help.
Thank.
, .
dr[0] = DateTime.Now.Date;
DateTime.ToShortDateString
<asp:Label ID="Label1" runat="server" Text='<%# ((DateTime)Eval("ItemValue")).ToShortDateString() %>'></asp:Label>
, , : datatable?
, . - . , . , , datatable UTF-8 UTF-16 , , . 12:00 , 1 0001 . .. , , .
, ASP.NET, . .
- , . , , "2/28/2011 12:00:00 AM". , .
, , - , , - . , "2/28/2011 12:00:00 AM". , . , . .