This tutorial shows how we can use the FormView control to display data from a SQL database, and also allow adding, updating and deletion of this data.

This tutorial uses an example SQL database to show how the FormView control can display data for a user to edit, delete and also add to the database.

We add a DropDownList control to enable selection of records, and a FormView control to allow display and editing of the selected record. Each of these controls will have their own SqlDataSource:

When the user updates, deletes or adds a new record using the FormView control, we need to tell the ListBox to update it’s list from the database.
The following code will also make the FormView appear once the user has selected an item from the drop-down list, and the initial item of (Select) in the list will disappear once the user has selected from the list.

Download Source Files