The issue is that you're using ApplyPropertyChanges
with a model object that has only been populated with data in the form (headline, story, and image). ApplyPropertyChanges
applies changes to all properties of the object, including your uninitialized DateTime
, which is set to 0001-01-01, which is outside of the range of SQL Server's DATETIME
.
Rather than using ApplyPropertyChanges
, I'd suggest retrieving the object being modified, change the specific fields your form edits, then saving the object with those modifications; that way, only changed fields are modified. Alternately, you can place hidden inputs in your page with the other fields populated, but that wouldn't be very friendly with concurrent edits.
Update:
Here's an untested sample of just updating some fields of your object (this is assuming you're using LINQ to SQL):
var story = _db.ArticleSet.First(a => a.storyId == ArticleToEdit.storyId);
story.headline = ArticleToEdit.headline;
story.story = ArticleToEdit.story;
story.image = ArticleToEdit.image;
story.modifiedDate = DateTime.Now;
_db.SubmitChanges();
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…