We use stored procedures for data access, if you're not comfortable with that you'll want to change that.As with all our code, this is a 'minimum needed to get it working example. However, to make use of the Details View control's advanced capabilities you must explicitly declare the row fields to include in the Details View control. The row fields specified are added to the Details View. Note: Explicitly declared row fields can be displayed in combination with automatically generated row fields. I have a Details View with a Drop Down List in an Edit Item Template, I know, pretty cool right?
When the Details View control is bound to a data source control, the Details View control can take advantage of the data source control's capabilities and provide automatic updating, deleting, inserting, and paging functionality. Input controls that are appropriate for the field's data type (such as a Text Box or a Check Box control) are displayed with a field's value for the user to modify.This property should be assigned with the Primary Key of the database table. We cannot retrieve the datakey values as the data is not yet bound to the details View control.After doing this, we can retrieve the Data Key value in the following ways. So, we call Databind() method in the Page Index Changed event handler and then retrieve the datakey value as shown in the code given below. The Details View control provides built-in capabilities that allow the user to update, delete, insert, and page through items in the control. In edit mode, the Edit button is replaced with an Update and a Cancel button. For more information, see Validation Server Controls. The Details View control can automatically add a Command Field row field with an Edit, Delete, or New button by setting the Details View. Unlike the Delete button (which deletes the selected record immediately), when the Edit or New button is clicked, the Details View control goes into edit or insert mode, respectively.