Note that all of the read-only items have an Edit button.However, the product Aniseed Syrup has had its Edit button clicked and is rendered in its edit mode.
Adding updating support to the List View requires that the List View's underlying data source control support updating.Clicking the Cancel button returns the item to its pre-editing, read-only state whereas clicking the Update button saves the user's modifications in the database (or wherever) and then returns the item to its read-only state, showing its newly updated values.The screen shot below shows a List View control that lists the products from the Northwind database table.While the List View control provides editing support, it requires a bit more work from the page developer to get it going.The reason is because the List View is defined by templates whereas the Grid View and Details View are defined by fields.The editing interface displays Text Boxes and Drop Down List controls for the various fields and has Update and Cancel buttons instead of the Edit button.
Whenever one of the Edit buttons is clicked a postback ensues and the List View begins its editing workflow.
This article walks through creating an editable List View control, with the finished results available for download at the end of the article. (It is assumed that the reader is familiar with how to edit data using a data source control.
If this is not the case, please first read Accessing and Updating Data in ASP.
This template must contain the data entry Web controls to collect the necessary inputs, along with Edit and Cancel buttons.
What input needs to be collected depends on the data source control's update logic.
Furthermore, the just-updated record's new values are displayed in the read-only interface because the data is rebound to the List View (step 7) after the update is issued (step 4).