Last post Oct 19, 2009 09:24 AM by sjnaughton
Oct 16, 2009 08:20 AM|beaucroco|LINK
I added several constraints to my tables. (ALTER TABLE...ADD CONSTRAINT....CHECK)
But then when I insert/edit data in my dynamicData application, if the data does not respect the constraint, an exception is launched.
Instead of this, I would like to have a red error message, like usual when there is problem with data type, not null...etc
How can I do ?
Thx for all.
Oct 16, 2009 09:23 AM|DaveRuss|LINK
Are you using Entity Framework?
If so, load your model into the designer, right click and select "Update Model from Database".
Remember, DD doesn't care about your database - it only cares about the model.
I suspect there's something similar with Linq-to-Sql, but I haven't used that so I don't know how the model stays in sync with the database.
Oct 16, 2009 10:27 AM|beaucroco|LINK
Unfortunately, I'm using LINQ TO SQL. My model is a dbml file, and you're right, DD only check the model ...
I suspected too, but I don't find something like that...I erased my designer file, drag-and-dropped my tabels again, to regenerate the designer, but it had no effect. I guess constraints are not written in this designer ...?
Oct 18, 2009 08:08 AM|sjnaughton|LINK
Hi Beaucroco, try this
http://blogs.msdn.com/davidebb/archive/2008/12/11/handling-database-exceptions-in-dynamic-data.aspx from David Ebbo.
Oct 19, 2009 03:51 AM|beaucroco|LINK
Thx Steve, it seems to be what I want.
But I don't understand how to use. Where do I need to put the code ?
The SubitChanges call inside the override methode is not recognized.
Oct 19, 2009 05:55 AM|sjnaughton|LINK
Hi Beaucroco, if you e-mail me using the 'contact' button I'll send a sample using Northwind for you to look at [:D]
Oct 19, 2009 09:24 AM|sjnaughton|LINK
Hi Beaucroco, I've sent you the sample, note that all the pages below:
Have been modified (ListDetails.aspx the most) to allow delete validation to be passed through to the pages ValidationSummary mostly this is just setting the Delete button to CausesValidation=”true” but on the ListDetailsPage you will need to setup all the
FiledTemplate to be able to set the validation on the Delete button and will not be able to use AutoGenerateXXXX buttons this applies to both the GridView and DetailsView.
Hope this helps