Problem with Data shown in table only

Problem with Data shown in table only Posts: 8Questions: 3Answers: 0

Error messages shown: Unable to cast value to be String
Description of problem:
Hi, I'm usign Datatables Editor .NET Framework
I need to reproduce this example but I've got always "Unable to cast value to be String"
I don't use a fixed Model but create field on fly; this is my controller class

private ActionResult DoAction(string table, System.Web.HttpRequest request, string action = null)
    bool action_defined = !string.IsNullOrWhiteSpace(action);
    GestioneDizionarioModel page_model = new GestioneDizionarioModel(table);
    DtResponse response = null;

    using (Database db = DbExtensions.GetDatabaseConnection())
        Editor editor = new Editor(db, table, "chiave");
        if (!string.IsNullOrWhiteSpace(action))
                new Field("last_update", typeof(DateTime), null)
                .SetFormatter(Format.DateFormatToSql("yyyy-MM-dd HH:mm:ss"))
        foreach (FieldInformation field in page_model.dizionarioModel.fields)
            editor.Field(new Field(;

        if (action_defined && action.Equals("remove"))
            // Disallow delete just in case anyone uses the API to do it
            editor.PreRemove += (sender, args) => args.Cancel = true;

        response = editor.Data();

    if (action_defined)
        DizionariCondivisiLogger.LogUpdateStatisticheDizionario(table, DbExtensions.GetTableRowsCount(table));

    return Json(response);// new { response = response });

How can resolve? Thanks!

This question has an accepted answers - jump to answer


  • allanallan Posts: 52,836Questions: 1Answers: 8,106 Site admin

    You'll need to use a string type for the DateTime I'm afraid. The problem with using DateTime is that it can't be directly represented in JSON, which we use as the transport format.


  • allanallan Posts: 52,836Questions: 1Answers: 8,106 Site admin
    Answer ✓

    I should note that you can still use DateTime in the db!!! Only in C#-land does it need to be a string.

  • Posts: 8Questions: 3Answers: 0

    I read a lot of time .NET Editor example "Table only data" and I found only now that there is a trigger on table users

    I'm going to implement this solution,

Sign In or Register to comment.