This post is a continuing sample demonstration of these two posts:
• ListView Control in ASP.NET 3.5 – 1 (opens a new window)
• ListView Control in ASP.NET 3.5 – 2 (opens a new window)
It would be a good practice to read them first before jumping into this post.
Using EditItemTemplate with ItemCommand
I will try to show how to add an editing capability to the ListView in this post by utilizing ItemCommand event. This event is basically raised when a button inside the ListView is clicked.
Following code should be added inside the ItemTemplate and AlternatingItemTemplate templates:
After adding the above code, EditItemTemplate template should also be placed somewhere between the ListView tags like the other templates:
Even though Edit, Update, Cancel and Delete buttons have built-in functionalities about what they are supposed to be doing, I will only use this advantage for Edit and Cancel buttons. Edit button puts the row in an edit mode by rendering the EditItemTemplate that I defined above. Cancel button invokes its built-in functionality which cancels the edit operation by raising the ItemCanceling event. For other buttons, I prefer to write their own custom routines:
As a result of these modifications, the result on the browser should look like:
When the Edit button is clicked:
Remember that I put RequiredFieldValidator controls for Country Name and Capital City textboxes (look at the 3rd screenshot in this post). Therefore, any operation in the edit mode (Update, Cancel or Delete) will not take action if one of these or both fields are blank:
Download
For more understanding of this post, you can download the sample (by VWD 2008) via here.
Monday, March 14, 2011
Subscribe to:
Post Comments (Atom)
Popular Posts
-
Recently I encountered a case when I knew much more about the data than the optimizer. Originally the performance was horrible, this is why...
-
ASP.NET 4 adds built-in support for using routing with Web Forms. Routing lets you configure an application to accept request URLs that do...
-
Introduction Web Service is known as the software program. These services use the XML to exchange the information with the other software wi...
-
Most experienced developers will tell you that end users tend to "judge an application by its cover". In other words, they don...
-
Introduction Advanced Integration is for sellers who want more flexibility when creating payment buttons. Advanced Integration facilitates t...
No comments:
Post a Comment