I think I've found another CodeFirst problem, here's my code...
[Field(FormPages.Registration, FormFieldsets.Details, Type = typeof(CheckBoxList), Prevalues=new string[]{"Yes, I agree"}, Caption="Please tick this box if we may record your email address to contact you in the future regarding your benefits" )] public string Message { get; set; }
It returns this...
Object of type 'System.Collections.Generic.List`1[System.String]' cannot be converted to type 'System.String'.
That did the trick except that I now get this on submission of the form! It's pretty hardcore!
inner exception
{"Violation of PRIMARY KEY constraint 'PK_UFRecordDataString'. Cannot insert duplicate key in object 'dbo.UFRecordDataString'. The duplicate key value is (2dffd1f8-bf13-44d1-bc7e-5c5dfdeadd2b).\r\nThe statement has been terminated."}
CodeFirst error on CheckBoxList prevalues
Hi Tim
I think I've found another CodeFirst problem, here's my code...
It returns this...
Object of type 'System.Collections.Generic.List`1[System.String]' cannot be converted to type 'System.String'.
Please save my bacon!
Martin
Comment author was deleted
Hi Martin,
Change the type of your property from string to List<string> that should do the trick (since a checkboxlist can return multiple items)
Hi Tim
What like this?
Prevalues will only accept a string array, string[]
Comment author was deleted
No
becomes
public List<string>Message{get;set;}
Hi Tim
That did the trick except that I now get this on submission of the form! It's pretty hardcore!
inner exception
{"Violation of PRIMARY KEY constraint 'PK_UFRecordDataString'. Cannot insert duplicate key in object 'dbo.UFRecordDataString'. The duplicate key value is (2dffd1f8-bf13-44d1-bc7e-5c5dfdeadd2b).\r\nThe statement has been terminated."}
Comment author was deleted
Yeah was a bug that got into 3.0 and 3.0.1 , you'll need to update the db here is the script
ALTER TABLE UFRecordDataString
DROP CONSTRAINT PK_UFRecordDataString
GO
Hi Tim
Executed the SQL successfully but i'm still getting the error, any ideas? I tickled the web.config.
Martin
Comment author was deleted
Are you sure it's executed on the correct db? Since if the constraint is gone it can't throw the error anymore...
Comment author was deleted
If you have sql management studio you can double check and see if the table doesn't have the constraint anymore...
Hi Tim
Sorry I was being a plebb and made the change to staging instead of local. Oh well, both needed the change.
Thanks as always
Merry Christmas to you!
Martin.
is working on a reply...