How do I create and populate an asp:FormView in an Asp.Net application dynamically in the code behind ?
Posted on 2014-07-23
I'm working on an ASP.net (VB.Net) application.
We have a page from which we display a ModalPopupExtender(s) tied to a input button click.
We would like to embed an asp:FormView control within the popup div.
Depending on the scenario, the use can edit one of several different record types.
With this in mind, we would like to be able to create and populate the item templates
dynamically in the code behind.
Ideally, we would like the FormView to display it's items in a grid consisting
of multiple rows/columns (<td>label </td><td>Field</td>
The template contents would depend on the current record type.
We won't be editing all the fields in the records, just a subset.
We would like to use the FormView to:
a) view record details
b) update a record
c) create a new record
How do I go about doing this dynamically in the code behind?