DateTime data in RadGrid

6 posts, 0 answers
  1. Harri
    Harri avatar
    6 posts
    Member since:
    Feb 2015

    Posted 11 Apr Link to this post

    Hi

    We have "datarow" in class and "dataset" is from ObservableCollection. There are normal set and get for public properties. We use ObjectDataSource to get "dataset" and there are also insert, update and delete commands. All other things seems to work but we have problems with DateTime type properties. Those are tested in GridBoundColumn and GridDateTimeColumn and always same problem. Those are shown correctly with user date format or given datastringformat but when updating or inserting it always crash before our own codes to conversion from "System.String" to "System.DateTime". Only way we have got it work properly is use ISO standard type format "yyyy-MM-dd HH:mm:ss" when setting the value which is not acceptable way to work. So how these datetimes should be set to columns that those are shown and editable in user format and not crash somewhere before it even get to our own code?

  2. Maria Ilieva
    Admin
    Maria Ilieva avatar
    4017 posts

    Posted 14 Apr Link to this post

    Hello,

    Note that when you are using DateTime column or a Bound column with DateTime set the System.DateTime you should pass DateTime type of fields form the DB to those columns. Otherwise you should perform manual conversion of the data before inserting it into the DB.

    Regards,
    Maria Ilieva
    Telerik
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Harri
    Harri avatar
    6 posts
    Member since:
    Feb 2015

    Posted 14 Apr in reply to Maria Ilieva Link to this post

    Hi

    We are using DateTime from db (Oracle db field named EnrollmentDate type Date) to class properte (Enrollment class with property EnrollmentDate) to observablecollection with that class (ObservableCollection<Enrollment>) and to asp elements.

    Below are two asp parts (Bound or DateTime) which has been tested:

    <telerik:GridBoundColumn DataField="EnrollmentDate" HeaderText="EnrollmentDate" SortExpression="EnrollmentDate" UniqueName="EnrollmentDate" DataType="System.DateTime" FilterControlAltText="Filter EnrollmentDate column"></telerik:GridBoundColumn>
     
    <telerik:GridDateTimeColumn DataField="EnrollmentDate" HeaderText="EnrollmentDate" SortExpression="EnrollmentDate" UniqueName="EnrollmentDate" DataType="System.DateTime" FilterControlAltText="Filter EnrollmentDate column"></telerik:GridDateTimeColumn>

     

    In Class "Enrollment" that property "EnrollmentDate" is defined as follows:

    public DateTime? EnrollmentDate
    {
        get
        {
            return _EnrollmentDate;
        }
        set
        {
            _EnrollmentDate = value;
            OnPropertyChanged("EnrollmentDate");
        }
    }

     

    Setting data to that class property from DB:

    objEnrollments.EnrollmentDate = dr.Field<DateTime?>("EnrollmentDate");

     

    So where is the problem point?

     

    If there is no problem, where is your mentioned before inserting, because it crash just after clicking update/insert button and not go in any event (or I haven't find right one).

     

    BR

    Harri

  5. Maria Ilieva
    Admin
    Maria Ilieva avatar
    4017 posts

    Posted 19 Apr Link to this post

    Hi,

    Can you please send us the full error stack trace so that we can revise it locally and investigate further for its root cause?

    Regards,
    Maria Ilieva
    Telerik
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
  6. Harri
    Harri avatar
    6 posts
    Member since:
    Feb 2015

    Posted 12 Sep in reply to Maria Ilieva Link to this post

    Hi,

    Sorry for long reply, some other projects :) Co worker found that there is solution for this. That was adding ParsingCulture="Current" to ObjectDataSource which we used for grid. So there is no more problems with datetime (or decimal numbers).

     

    Regards,

    Harri

  7. Maria Ilieva
    Admin
    Maria Ilieva avatar
    4017 posts

    Posted 14 Sep Link to this post

    Hello Harri,

    Thank you for getting back to us and for the provided update on this case. Do not hesitate to contact us back in case further assistance is needed.

    Regards,
    Maria Ilieva
    Telerik by Progress
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017