Here i my c sharp code of controller api class DefComapny whose value are always null while posting a data from kendo grid thats why not entering any thing to database?

   [HttpPost]
    public void SaveDefCompny()
    {
   var result = new List<DefCompany>();
        using (var data = new RPDBEntities())
        {
            DefCompanyDTO productViewModel = new DefCompanyDTO();

                var product = new DefCompany
                {
  //same problem of all entites  getting no value from grid

                 Id = productViewModel.Id, // getting no value from grid
                    CurrentCurrencyCode = productViewModel.CurrentCurrencyCode,
                    ShortName= productViewModel.ShortName,
                    FullName= productViewModel.FullName,
                    ContactPerson= productViewModel.ContactPerson,
                    Address1= productViewModel.Address1,
                    CompanyCity= productViewModel.CompanyCity,
                    CompanyState= productViewModel.CompanyState,
                   CompanyCountry= productViewModel.CompanyCountry,
                   ZipPostCode= productViewModel.ZipPostCode,
                   TelArea= productViewModel.TelArea

                };
               result.Add(product);
               data.DefCompanies.Add(product);

             data.SaveChanges();
        }

    }

here is my viewmodel code

   document.onreadystatechange = function () {
var viewModel = kendo.observable({

    products: new kendo.data.DataSource({

    schema: {
       //data:"Data",
        total: "Count",

        model: {
            Id: "Id",
            fields: {
                Id: { editable: true, type: "int" },
                ShortName: { editable:true, type: "string" },
                FullName: { editable: true, type: "string" },
                ContactPerson: { editable: true, type: "string" },
                CurrentCurrencyCode: { editable: true, type: "int" },
                Adress1: { editable: true, type: "string" },
                CompanyState: { editable: true, type: "string" },

                CompanyCity: { editable: true, type: "string" },
                CompanyCountry: { editable: true, type: "string" },
                ZipPostCode: { editable: true, type: "string" },
                TelArea: { editable: true, type: "string" }

            }
        }
    },
    batch: true,

    transport: {
        read: {
            url: "/api/Companies/GetAllCompanies",
            dataType: "json"
        },
        create:{

            url: "/api/Companies/SaveDefCompny", 
            dataType: "json"
        },
        update: {
            url: "/api/Companies/SaveDefCompny", // here you need correct api url
            dataType: "json"
        },
        destroy: {
            url: "/api/Companies/Delete", // here you need correct api url
            dataType: "json"
        },
        parameterMap: function (data, operation) {
            if (operation !== "read" && data) {
                 return  kendo.stringify(data) ;


            }
        }
    }

})
});
kendo.bind(document.getElementById("example"), viewModel);


}

how should i pass my inline kendo grid values to my controller so that it save it in database?

Related posts

Recent Viewed