ASP.NET MVC Persisting mdoel's ID value when Editing
Posted
by user295017
on Stack Overflow
See other posts from Stack Overflow
or by user295017
Published on 2010-03-16T23:15:30Z
Indexed on
2010/03/17
0:01 UTC
Read the original article
Hit count: 258
public Edit(int? id){ /* Codes */ }
[HttpPost]
public Edit(Item model){ /* Codes */ }
I retrieve a copy of Item in the first Edit method, which would contain a value for ItemID. But when it gets to the HttpPost method, the id value's lost.
If switched to
public Edit(int? ItemID){ /* Codes */ }
[HttpPost]
public Edit(Item model){ /* Codes */ }
this way ItemID can be persisted in the Item model. But is this a good way to handle it? Will ASP.NET MVC always be able to know that it needs to plug "ItemID" into Item? and are there other ways to persist the ID value? Thanks.
© Stack Overflow or respective owner