Using DataAnnotations in MVC 2 – Catching up to Dynamic Data

  DataAnnotations help you write robust validation and prevent the type of annoying error message shown above. Form submittal failure when a field doesn’t validate can be very frustrating –  especially when there is no indication of the problematic property or the constraint violation. I happened to get the Outlook error above when I attempted…


New Templated Helpers Improve SoC

  SoC (from WikiPedia)In my MSDN article Walkthrough: Using Templated Helpers to Display Data I show how to annotate your data model to specify that a field should be rendered with a type-specific control.  The download sample code also includes a control using the new Html.EditorFor helper. With one line of code you can open…

3

Setting font attributes with UIHint in your Entity Partial Class

  I’ve written a simple Field Template ( RedBold.ascx ) that reads most font attributes and applies them to your field values. The new entity templates make it easy to apply font attributes to the field labels. The image below shows several font attributes applied to the partial class for the Customer table of the…

1

Dynamic Data FAQ

Please post corrections/new submissions to the Dynamic Data Forum. Put FAQ Submission/Correction in your title. See Tips on getting your ASP.NET Dynamic Data questions answered quickly Post LINQ To SQL Questions herePost Entity Framework Questions here Links that will answer questions: From the Dynamic Data architect David Ebbo Handling database exceptions in Dynamic Data A…

2

Custom Validation Error message not displayed

  A customer pointed out that his Spanish validation error messages were not being displayed; the default Error message was shown instead.  I’ll use the Products table from the NorthWind Db to reproduce the problem and show a work-around. Create a partial class for the Products entity: [MetadataType(typeof(ProductsMD))] public partial class Products { public class…

3

Explicit connection string for EF

The default constructor for the ObjectContext class in the  Entity Data Model (EDM) retrieves the construction string from the web.config or app.config file. If you have multiple data models or need to pass in the the construction string at run time you must use the ObjectContext constructor that takes a construction string. (Note: Be sure…

6

Improving the FK field display: Showing two fields in Foreign Key columns

  The default scaffold of the CustomerAddress table in the AdventureWorksLT database poses a problem: Dynamic Data (DD) defaults to using the first string field in the referenced table. In this case, the first string field is the Title field (Mr,Ms, and so on).  The image below shows the problem with the FilterRepeater drop down…

10

How to create an updateable view with ADO Entity Framework and with LINQ to SQL

Creating an update-able view with  ADO Entity Framework (EF) or LINQ to SQL (L2S) is a fairly advanced topic and not directly associated with Dynamic Data. At the end of the article I have a sample console application to verify the modified L2S data model allows updates on a view. To create an update-able view,…

6

Tweaking the Filter Repeater

The default implementation of Dynamic Data provides a drop down list box for each foreign key and boolean field in a table. The drop down list allows you to filter the table with the value selected from the drop down list box. The figure below shows a view of the Product table from the AdventureWorksLT…

4