A look at data sources in umbraco contour

To continue the series on umbraco Contour, in this post I’ll show you how you can use the data sources feature in Umbraco Contour. When you navigate to the Contour section (if you have Contour installed, otherwise you can install it from the package repository, developer section/ packages / package repo / umbraco pro) you’ll notice 3 trees in the treeview on the left. Forms, Data Sources and Prevalue Sources.


Data Sources allow you to create a form based on a Data source and submit your form entries to that data source. By default there are 3 types of data sources

  • Save as node (create form based on document type and create an umbraco content document on submit)
  • SQL Database (create form based on database table and submit data to that table)
  • Webservice (create form based on webservice and post to that service on submit)

In this post I’ll use the SQL Database data source type.

I have the following database that contains a subscription table with some sample fields including a title field which is a foreign key of a title table.


So now I want to add a form to my site that submits records (subscriptions) to this table. Using data sources in Contour you can do this without a single line of code, just by completing a simple wizard.

The first step is to create a new datasource (so simply right click the data sources tree and select create and then provide the new data source a name). Once the data source is created the next step is to select the type, in this case it will be ‘SQL Database’


Once the type is selected the settings for the specific type should load. In case of the ‘SQL Database’ type there are 2 settings.

  • Connection string
  • Table name


Once these are setup correctly and the datasource is saved you should get a ‘create form’ button, this will start the form creation wizard.


In the first step of the wizard you’ll need to select which db columns you want to include on the created form (if the db columns doesn’t allow nulls this will be autu checked).


Depending on the presence of foreign keys the next step will be to setup the foreign keys, so you’ll have to select which column will be used to display


And the final step allows you to map a fieldtype to each of the fields that will be created


Once that is setup simply hit the ‘save form’ button and a new form will be created

Since the form is linked to a data source you’ll have limited editing possibilities


That’s it now we have a form that will submit data to a custom database table, without writing a single line of code but by simply completing a 3 step wizard.

And it’s of course also possible to extend these data sources by creating your own, check out the contour shared sourcecode and take a look at the default data sources code.

4 Comments so far

  1. sdf on February 5th, 2012

    I want to download the code but the url of the web dont work

  2. Alex R on January 21st, 2013

    Hi Tim,

    Great post, very helpful.

    Do you have any information or examples on how to use a webservice as the datasource?

    Also is it possible to generate a database table based on the form you create in Contour?

    In the example above Contour requires a predefined table structure which you map to the form fields. Is it possible to create the form fields and from them create a database table based on the form fields, by using the webservice as the datasource?


  3. Brett on July 24th, 2013

    Yeah, I can’t find any examples ANYWHERE on how to use the webservice datasource, this would be great if you could show us where to find this?

  4. Eric Schrepel on September 20th, 2013

    Related question: using Contour 3.0.15 and Umbraco 6.1.5, we’ve tied a few forms to SQL datasources. The problem is, if I create a datasource then base a form on it, then later remember I need to add an additional field from the underlying table, I can’t see how to do that. So far, I’ve had to just ditch the whole form and start anew.

    Also, would be great to be able to copy an existing form which could be tweaked for an alternate use.

    Also, a couple UI tweaks: when editing a data source, then clicking the Forms tab, the dialog shows two categories: 1) “Create new form”, and 2) “Forms using this workflow”. Seems #2 should be “Forms using this datasource”.

    Lastly, more prominent information about how to pass a variable from a page into an Umbraco form would be welcome. Have searched our.umbraco and sort of found info, but there’s no clear instruction out there.

    Thanks for the product; it’s largely serving us well, though I’d love more documentation about how to make designing/working with forms easier (esp. in Umbraco 6’s Razor environment).

Leave a Reply