Start Net formview itemupdating

Net formview itemupdating

For the Edit and New buttons you'll need to include the Form View's Mode Changing event in your code file; unlike the Page Index Changing event, this time you'll have to put code in it.

If you now run your page, it will display the collection's first item.

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.

I first check to see if the List is in the Session object and, if it isn't, build it.

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.

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.

NET Data Views are powerful tools when coupled with a Data Source.