none
DateTime in a dataview (sort and display) RRS feed

  • Question

  • Hi,

    I have a DataTable which takes its data into a Sharepoint site.

    One of the column is a date. I used to convert those dates to string so i had no problem but when it comes to sort this column it can't work with strings (obviously 10-23-2007 will be considered as before 11-23-2002).

    So i did convert my column and now have a DateTime :

     

    DataTable dtTasks = new DataTable();

    dtTasks.Columns.Add("DueDate",Type.GetType("System.DateTime"));

     

    And then the date is correctly inserted into the datatable.

     

    My problem is that it s displayed as "06/27/2007 00:00:00" because the DateTime format includes the time and i don't want it. Is there any simple way to get rid of the time into a dateTime ?

     

    Secondly it appears that the sorting method works only in DESC and not in ASC, any idea on how to solve this ?

     

    Thanks,

    Wednesday, November 7, 2007 10:43 AM

Answers

  • Hi, the DataTable/DataView have not property to format any value. This property is over controls in the WebForm/WinForms.

     

    You must bind your datatable over any control and assign value at property Format in this control. The data in your datatable is only to work it, to display this info you must be formated.

     

    The sort work fine, please paste an example code.

     

    regards

     

    Claudio

    Wednesday, November 7, 2007 1:30 PM

All replies

  • Hi, the DataTable/DataView have not property to format any value. This property is over controls in the WebForm/WinForms.

     

    You must bind your datatable over any control and assign value at property Format in this control. The data in your datatable is only to work it, to display this info you must be formated.

     

    The sort work fine, please paste an example code.

     

    regards

     

    Claudio

    Wednesday, November 7, 2007 1:30 PM
  • thanks for your answer.

     

    I'll try to bind the datatable differently but i find it quite complex as it comes from SharePoint elements so i don't have full control on these.

    I don't know how i can get another type than System.DateTime with this source.

    But then it becomes a Sharepoint problem so i ll try to figure it out.

     

    I ve solved the sorting problem which was only a (stupid) mistake.

     

    Thank you

     

    Wednesday, November 7, 2007 2:37 PM