Select, confirm, delete multi-line checkbox list
Selecting, Confirming & Deleting Multiple Checkbox Items In A DataGrid (ie HotMail & Yahoo) Introduction Although I do not have either a Hotmail or Yahoo email account, I do have friends that do, and I have often seen them check their email and noticed how it was all neatly displayed in a table. Right next to each item in their e-mail table was a simple little checkbox. At the bottom or top of this table you would have another checkbox giving them the ability to select all of the e-mail, and a button to submit back. Once this was done they would receive a nice popup alert to confirm what's about to happen, and then once this is OK 'ed, boom, all the selected items are deleted. .NET , of course, has the DataGrid, their finest and most popular control to date, and it should be pretty easy to get the same functionality, right? Well, not quite. Doing this with .NET is not that straightforward and functional as I would 'velked it to be. Sure it's quite easy to add an Edit / Update Button or link to each row and even a delete button to each, alongside a pop up alert as well! However, applying this delete feature to each and every button and deleting them one by one is a little maddening. Nor is the DataGrid set up in allowing a way of adding a main "select all" checkbox to easily select all of the boxes, and then applying any particular action. In this article, we will examine how to create a fully functional DataGrid with all the features you'd find set Up on hotmail or yahoo. as an added bonus we'll be Performing All of Our data tasks strictly utilizing microsoft '
s new Data Access Application Block or DAAB v2. To any who may feel a little behind with DAAB, have no fear, everything here can still be accomplished with pre-DAAB data objects as the only difference here is the data access part of it. Trust me there is a huge difference between the two, for one DAAB enable you to write about 75% less code that you would normally need when compared with regular ADO.NET! So, before we begin, download the DAAB dll from the above link , install it, and copy it into you application's bin folder and you're ready to go. Also, be sure and take a peek at the DAAB documentation that came with your installation for an overview and any questions you may have. Ok, let's get to it then. Our fully-featured DataGrid Selecting & deleting multiple items will definitely be set up quite differently than any other type of .NET DataGrid deleting you probably have seen. However, we'll still follow the same logical flow of deletion, And We'll Still Confirm Any Delete Actio ns about to take place after we have selected all our items. Much of the magic in making this work is really going to come from client-side JavaScript, that is ultimately responsible for wiring up our main "select all" checkbox to handle the selecting and deselecting of our checkboxes. Also, included is our server-side delete method that erases our data, and a DataGrid refresher method to rebind our DataGrid after we have completed our data deletion. Have a look at Figure 1 to get an idea of what Your DataGrid Will Look Like: Figure 1 Here Is The Code To Set Up Our DataGrid: