Formview onitemupdating

If you have noticed I have set the command Name property of the edit Link Button to "Edit" so I can catch its event in the Form View Item Command event.

Since, there are several Link Buttons inside the Form View control the command Name can be used to distinguish between different events generated inside the Form View through Link Buttons.

Take a look at the code below which switches the Form View control between different modes. Command Name property is "Edit" the Form View mode is changed to Form View Mode. Command Name is "Cancel" then it changes to the "Read Only" mode. Command Name is Update I do not switch to any mode because on update I need to retrieve the values from the Text Boxes and send them to the database to update the data.

The main purpose of the HTML table is just to position items in a well ordered manner. NET Label controls to display the information inside the Item Template.

Take a look at the screen shot below to have a clear idea.

Now, it is time to write some code to enable paging.

You will need to implement the Page Index Changing event of the Form View control which is fired when the paging link buttons are clicked.While there are other techniques you can use with Linq to SQL to avoid the issue above, the point of this post is to show how the Form View handles null values.The workaround is to subscribe to the Form View Item Updating event and look for string.empty New Values and set those to null instead.In this article I will demonstrate that how you can enable paging and switch between different modes in the Form View control which includes (Edit, Update and Cancel) ASP.NET 2.0 came out with several cool data bound controls which includes Grid View, Details View and Form View. NET 3.5 SP1This post describes two gotchas with the Form View control when binding:1) When performing two way databinding, Null values and Nullables get changed to string. 2) Two way binding is not supported for nested controls.