Hi there,
The code that's causing the error is from the autogenerated code for the Entity Framework model. Tyeh reason you're getting this error is because you'e trying to assign null to the ImageUrl property because you forgoty to take out the TextBox for the ImageUrl:
Code:
<asp:TextBox ID="ImageUrlTextBox" runat="server" Text='<%# Bind("ImageUrl") %>' />
With this line in the InsertItemTemplate, ASP.NET tries to assign the value of the TextBox to the ImageUrl control. This fails because a) the Text is null, and b) ImageUrl doesn't allow nulls.
Once you take out this line, ASP.NET doesn't assign an explicit value to the ImageUrl property (under the hood it's still null, but validation is postponed until you save the item to the database). Then the Inserting event fires and you manually assign the ImageUrl a valid value so that when you save, everything works well.
Hope this helps,
Imar