For this example, I want to display my Customer object's First Name and Last Name properties, so I add two Labels and some text to identify the information to the template.Once the controls have been added to the template, you can bind them to the object's properties. NET Data Views are powerful tools when coupled with a Data Source.With the Form View (or any of the Data Views), I normally use a Data Source to move data from some data store and into/out of the view.
I then set the Form View's Data Source to the List: Next, you must add these two lines of code to the page's Pre Render event so they execute after any activity you perform with the Form View elsewhere in the Page.The general pattern is to add a Button to your template with a key word in the Button's Command Name property. NET sees those Command Name values, it will fire an event and you'll need to put some code in that event.To support changing existing object, for instance, you need to add a Button with its Command Name property set to Edit to your Item Template; to support inserting objects, a button with its Command Name property set to New; for deletes, a button with its Command Name set to Delete.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 code to retrieve Data Key value in the Data Bound event of details View control is given below.On the Edit Item Template, the controls will be displayed with data from the current object; on the Insert Item Template, the controls will be displayed with no data.You'll also want to add two buttons to each template: on the Edit Item Template, a Button with its Command Name set to Update; on the Insert Item Template, a Button with a Command Name set to Insert; on both templates, a Button with its Command Name set to Cancel.However, the Form View (and the rest of the Data Views) will work just as well with any collection of objects: Lists, Arrays, Array Lists, or whatever collection you want to make available to the user for display and update.You won't get automatic generation of the Data View's templates and you'll have to write a little code, but from the user's point of view, everything works as if your Data View was tied to a Data Source.As you would if working with a Data Source control, click on the Label's Smart Tag and select Edit Data Bindings.When the Data Bindings dialog appears, the dropdown lists that normally display the items you can bind to will be empty.