Thursday, July 23, 2009

FormView does not render

I came across this one today. And it took me a few minutes to see it.

I wanted to use the Item-, Edit- and InsertTemplate from the FormView but I didn't want to use the out-of-the box DataBinding.

As it turns out, the FormView needs a DataSource. The MSDN documentation makes this very clear.

A FormView displays the values of a single record from a data source using user-defined templates. The FormView control allows you to edit, delete, and insert records.

And yes, it's pretty logical, but what if you want to use a FormView without DataBinding? You can simply create a fake DataSource.

I did something like this.

I created a list of Objects containing one Object and binded that to the FormView and it works like a charm.

1 comment:

  1. nice post, great thank's I had some issue with this too. Me and my colleague where struggling with it