TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
vicky t
NA
2
539
Unable to add variable values to DB using TryUpdateModel
Feb 5 2020 5:03 AM
I have a variable which has values and I am trying to add to DB using TryUpdateModel and eventually it doesn't happen.
Getting below error message.
[HttpPost]
public
ActionResult CreateAccount(FormCollection collection)
{
string
msg =
string
.Empty;
try
{
var accountdetail =
new
AccountDetail();
TryUpdateModel(accountdetail);
AccountRepository userRepo =
new
AccountRepository();
if
(userRepo.CreateUser(EntityHelper.InitializeUser(accountdetail, 0)))
return
Json(
new
{ Result =
"Success"
, InfoMsg = msg });
else
msg =
"Error returned"
;
}
catch
(Exception ex)
{
msg = ex.Message;
}
return
Json(
new
{ Result =
"Failed"
, InfoMsg = msg });
}
Error Message:
Property set method not found.
at System.Reflection.RuntimePropertyInfo.SetValue(Object obj, Object value, BindingFlags invokeAttr, Binder binder, Object[] index, CultureInfo culture)
at System.Reflection.RuntimePropertyInfo.SetValue(Object obj, Object value, Object[] index)
at PerpetuumSoft.Knockout.KnockoutUtilities.ConvertData(Object data)
at PerpetuumSoft.Knockout.KnockoutUtilities.ConvertData(Object data)
at PerpetuumSoft.Knockout.KnockoutModelBinder.BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
at System.Web.Mvc.Controller.TryUpdateModel[TModel](TModel model, String prefix, String[] includeProperties, String[] excludeProperties, IValueProvider valueProvider)
at System.Web.Mvc.Controller.TryUpdateModel[TModel](TModel model)
at WebApp.Controllers.AccountController.CreateAccount(FormCollection collection) in C:\Code\AccountController.cs:line 166
Exception is thrown at this line
TryUpdateModel(accountdetail);
Really appreciate any inputs.
Reply
Answers (
0
)
How to scan virus for Upload docs using Window defender C#
How to select folder path in mvc