Introducing the new Dynamic Data

Today, we released the ASP.NET 3.5 Extensions Preview, which includes the exciting Dynamic Data feature.

A lot has happened since we released an early version of Dynamic Data Controls in the May ASP.NET Futures release.  While it was already an exciting feature, it was not very customizable and was limited to a small set of scenarios.

While this new version preserves the essence of the original, it is also completely different.  Not only it addresses the limited customization, but it also brings a lot of new things.

Since most of you are likely new to Dynamic Data, let me start with a quick introduction of what it is about.  The core purpose is to make it easy to write powerful and extensible data driven web application.  Here are some of the steps involved (not all of them are necessary):

  1. Define your model: this step is not specific to Dynamic Data, but this is where it all starts.  You have a database, and you create a model for it.  Currently, this is done using Linq to SQL.  In the future Linq to Entities will be supported as well.

  2. Test a scaffolded version of your app: with no additional effort, Dynamic Data lets you run a scaffolded web application on top of your schema.  Although this scaffold has a ‘standard’ UI, it lets you try all CRUD operations on your tables.  Furthermore, it has full support for relationships.  For instance (assuming Northwind), the Products page would let you navigate to a product’s category info, and editing a Product’s category would show you a rich drop down with category names (instead of IDs).

  3. Customize the shared page views: you then get to make changes to the page templates that are used to display the scaffolded views.  That, you can make changes that will affect the view of all the tables.

  4. Customize the specific pages: the next step is to define some custom UI for specific pages.  e.g. you could write one of Products and another for Categories.  The nice thing is that while you do this, you still get the standard scaffolded view for all the other tables.  This lets you create specfic pages at your own pace, while keeping a functional application at every point.

  5. Annotate your model: you can add attributes to your model to add extra knowledge about certain fields.  e.g. you could set a Range on the product’s UnitsInStock field so it only allows values between 0 and 50.  The UI would then automatically pick this up and validate inputs accordingly.  The great thing is that you are keeping this information on your model, and don’t need to ‘pollute’ your pages with it.

  6. Create custom field templates: all fields in Dynamic Data are rendered via field templates, which are basically user controls.  You can also create custom templates, which can be very powerful.  e.g. in the above case, you could create a field template that renders a range as a slider control instead of a textbox.  Again, your page would pick that up without you having to add this custom UI directly in the aspx file.

Well, this should be enough for a quick introduction.  I’ll try to have a screencast available tomorrow, which will run through some of the basic scanerios.  I’ll then follow up with more specific posts and screencasts that go deeper into specific areas.

To ask questions or report issues about this feature, please use this ASP.NET forum.

Comments (11)

  1. La ASP.NET 3.5 Extensions Preview est disponible sur le site Téléchargez-la vite. Consultez

  2. Dan Miser says:

    Where do we report issues with this area? I have a repeatable stack trace that gets thrown (see below). I’d be happy to wrap it up into a test case that you can use to fix it if I knew where to go with it.

    Of course, if you know about this problem already, then never mind. 🙂

    Source Error:

    Line 4:      string GetDisplayString() {

    Line 5:          var column = (System.Web.DynamicData.DynamicMetaForeignKeyMember)MetaMember;

    Line 6:          return FormatDataValue(column.OtherMetaTable.GetDisplayString(DataValue));

    Line 7:      }

    Line 8:  </script>

    Source File: c:moonliteVendTrackVendTrackApp_SharedDynamicDataFieldsForeignKey.ascx    Line: 6

    Stack Trace:

    [InvalidCastException: Unable to cast object of type ‘System.Int32’ to type ‘System.String’.]

      System.Web.DynamicData.DynamicMetaTable.GetDisplayString(Object value) +138

    ASP.app_shared_dynamicdatafields_foreignkey_ascx.GetDisplayString() in c:moonliteVendTrackVendTrackApp_SharedDynamicDataFieldsForeignKey.ascx:6

    ASP.app_shared_dynamicdatafields_foreignkey_ascx.__Render__control1(HtmlTextWriter __w, Control parameterContainer) in c:moonliteVendTrackVendTrackApp_SharedDynamicDataFieldsForeignKey.ascx:10

    — stack trace continues on from here —

  3. davidebb says:

    Hi Dan,

    We have set up a forum for this feature, so this is the best place to report issues.  Here is the link:

    Could you repost it here and we’ll follow up there?

    Quick question for the follow up: what is the list of columns in the foreign key’s table?  I think this bug would happen if there are no string columns at all.  Good find!


  4. Dan Miser says:

    I posted over there with a bit more information, but yes, you hit it perfectly. There were no string columns in the FK table. Indeed, that is the workaround, to just add a simple unused varchar to that table.

    Thanks for your look into this!


  5. Dynamic Data es uno de los features de las ASP.NET 3.5 Extensions (a&#250;n en Preview ) que me llam&#243;

  6. Dynamic data is a very cool feature of the ASP.NET 3.5 Extensions that allows you to trivially easy build,

  7. Now that ScottGu blogged about it , we have received a number of great feedback and questions.&#160;

  8. Programming says:

    Dynamic data is a very cool feature of the ASP.NET 3.5 Extensions that allows you to trivially easy build

  9. Visual Studio 2008 和 .NET Framework 3.5 多了不少新玩意兒,例如:multi-targeting、更強的 Web UI designer、C# 3.0、VB 9.0、單步除錯時可直接 step into .NET Framework 原始碼、JavaScript Intellisense 、LINQ

  10. 不足道 says:


    作者HartmutWilms译者张海龙发布于2007年12月23日下午10时44分 社区