views:

368

answers:

2

I'm getting the following InvalidOperationException:

The parameter conversion from type 'System.String' to type 'System.Runtime.Serialization.ExtensionDataObject' failed because no type converter can convert between these types.

In a Post action on my ASP.Net MVC2 page, but I'm really not sure what it's referring to. I'm using data annotation validation:

public class FamilyPersonMetadata
{
    [Required(ErrorMessage = "Name Required")]
    public String Name;

    [Required(ErrorMessage = "Date of Birth required")]
    [DateTime(ErrorMessage = "Invalid Date")]
    [DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:d")]
    public DateTime DateOfBirth;
}

[MetadataType(typeof(FamilyPersonMetadata))]
public partial class FamilyPerson
{
}

And my view inhertis from a ViewPage with a subtype of FamilyPerson. I just create controls with names matching those of FamilyPerson and then submit the form, but for some reason my ModelState is invalid and the above error is apparently the reason. I'm quite perplexed as to the nature of the error. Similar code is working for other views and actions.

Could someone point me in the direction of things to look at that might cause this?

+2  A: 

Regarding [DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:d")]

"{0:d" should be "{0:d}"

Tim Hoolihan
Good catch. Sadly, I still get the same exception after that change.
Mike Pateras
A: 

It seems to have gone away on its own. Weird.

Mike Pateras