Quantcast
Channel: Editor — DataTables forums
Viewing all articles
Browse latest Browse all 3800

Id column from database model shows as null

$
0
0

I am learning how to use Editor in a .NET MVC project and am unable to solve an issue.

My database table has a primary key field called "Id".

While editor shows all of the other fields in my table with their correct values, the Id is consistently null.

What do I need to change so that Id is not null?
On a related note, changes I make on the inline editor do not persist on the database. My theory was that the null Id was part of it -- however as I receive no compiler, runtime, nor browser errors, I am not sure how to proceed.

Thank you

Controller Action

public ActionResult Table()
        {
            var settings = Properties.Settings.Default;
            var formData = HttpContext.Request.Form;

            using (var db = new Database(settings.DbType, settings.DbConnection))
            {
                DtResponse response;
                try
                {
                    response = new Editor(db, "TestTable")
                        .Model<TestTable>()
                        .Field(new Field("Id"))
                        .Field(new Field("Campus"))
                        .Field(new Field("Teacher"))
                        .Field(new Field("CourseSectionId"))
                        .Process(formData)
                        .Data();

                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                    throw;
                }
                return Json(response, JsonRequestBehavior.AllowGet);
            }
        }

Model

public class TestTable
    {
        public int Id { get; set; }
        public string Campus { get; set; }
        public string Teacher { get; set; }
        public string CourseSectionId { get; set; }
    }

Viewing all articles
Browse latest Browse all 3800

Trending Articles