TryUpdateModel is not working for new Record on ASP.NET MVC Page?
- by Rita
Hi
I have a customer Registartion page using ASP.NET MVC with fields like FirstName, LastName, Address from AddressDetail Table.
When i create a new object for CustomerMaster and trying to update the fields using TryUpdateModel, it is not updating.
But the TryUpdateModel is working fine on the Edit Profile Page and that particular record is referenced.
CODE on Registartion Page:
AddressDetail add = new AddressDetail();
bool status = TryUpdateModel<AddressDetail>(add, "addr", new[] { "FirstName", "LastName", "Address_1", "Address_2", "ZipCode", "City", "Phone", "Fax" }, formData);
CODE on Edit Profile Page:
AddressDetail addr = (from a in miEntity.AddressDetail
where a.AD_Id == 20
select a).First();
bool rc = TryUpdateModel<AddressDetail>(addr, "addr", new[] { "FirstName", "LastName", "Address_1", "Address_2", "ZipCode", "City", "Phone", "Fax" }, formData);
Does anybody run into same issue with TryUpdateModel? Doesn't it update the Model for New Record?
Thanks