Before the record is deleted we need to determine its PDF file s path, but we don t want to delete the PDF before the category is deleted in case there is some exception and the category is not deleted.The Grid View s // A page variable to "remember" the deleted category's Brochure Path value string deleted Categorys Pdf Path = null; protected void Categories_Row Deleting(object sender, Grid View Delete Event Args e) protected void Categories_Row Deleted(object sender, Grid View Deleted Event Args e) , then the PDF is deleted from the file system.When editing a category, the user will be able to optionally upload a new picture or have the category continue to use the existing one. In this tutorial we will extend the Grid View to include editing and deleting support.For the brochure, they can either choose to use the existing brochure, to upload a new brochure, or to indicate that the category no longer has a brochure associated with it. The DAL has auto-generated s header and choose Add Query from the context menu to launche the Table Adapter Query Configuration Wizard. Rather than continuing to work from page from the previous tutorial.
As discussed in the An Overview of Inserting, Updating, and Deleting Data tutorial, the Grid View offers built-in row-level editing support that can be implemented by the tick of a checkbox if its underlying data source is appropriately configured.The Grid View and Object Data Source provide events that fire both before and after the delete command has been performed.We actually need to create event handlers for both the pre- and post-action events.Figure 6: Add a Test Category with a Brochure and Image (Click to view full-size image) Figure 7: After Inserting the Test Category, it is Displayed in the Grid View (Click to view full-size image) In Visual Studio, refresh the Solution Explorer.You should now see a new file in the statement to be sent to the database.