.NET-MVC Modelbinder not binding because of primary key, all other fields are right. What's happenin

Posted by ropstah on Stack Overflow See other posts from Stack Overflow or by ropstah
Published on 2010-03-28T21:51:41Z Indexed on 2010/03/28 22:03 UTC
Read the original article Hit count: 147

Filed under:
|

I want to perform an Add object scenario in .NET using the modelbinder.

Function AddObject() As ActionResult
    Return View()
End Function
<AcceptVerbs(HttpVerbs.Post)> _
Function AddObject(<Bind(Exclude:="ObjectId")> ByVal o As BLL.Object) As ActionResult
    o.Save()
End Function

However, I get an error:

'o.ObjectId' is not declared or the module containing it is not loaded in the debugging session.

While inspecting the object, all other fields are set properly. I've tried all combinations regarding:

with/without Html.Hidden("ObjectId") to with/without <Bind(Exclude:="ObjectId")> and even setting o.ObjectId to Nothing, all with the same results.

What am I doing wrong?

© Stack Overflow or respective owner

Related posts about asp.net-mvc

Related posts about modelbinders