Deleting an entry from your "Recent Updates" List
By now I'm sure you're convinced that UltraDev is here to save the world and things will never ever have to be complicated again. What joy! What fun! Hallelujah!
Things start to get a little more complex from here in. In order to delete an entry, we need to have a recordset which only consists of one record. To get hold of that record, we need to perform a search. So this is really a two stage process.
- Find that pesky record
- Delete its big fat ass
What I'm not saying is that this is the only way to go about this process, but it is the easiest way to do it and to learn as much as possible along the way.
Stage 1: Find that pesky record
You need to create a page with a form. The form need to include the field we are going to search on - in our case Date.
I've again given my text field the same name as the database field - Date. The clever bit with this form is that we just submit it to another page. If we enter the name of another ASP page as the Action, and set the Method to GET, then the designated page will be able to pick up the output from the form.
You can save this page and worry about it later. Time to move on to Stage 2.
Stage 2: Delete its big fat ass
We now need to create a page to accept the output from this form. This page needs to do a number of things:
- Create a recordset based on the output of the previous page
- Display the selected record for visual confirmation
- Provide a Big Red Button to delete the item.
(This button is only Big and Red in the loosest senses of the words ... it's actually going to be small and grey, but a Small Grey Button holds less glamour, so Big and Red it is).
Create a new page, and we'll define a Recordset like we did before.
The important thing about this recordset is that it uses a filter. The filter as shown above is based on the Date field. The recordset is going to be filled with any records where the Date field matches the Date parameter passed through to the page (with the URL).
Basically, for us, this parameter is the value we entered in the form on the previous page. The results of the form will be passed along with the URL and this recordset filter will pick those up and use them to make its selections.
In our circumstance, the Date is only going to match one record. We will end up with the one record recordset I talked about waaaay up at the top of this page. Click OK.
We now need to insert the results as text into the page - to serve as a visual confirmation of the record which is to be deleted. I'm hoping you know how to do this by now - we covered it in the first tutorial of this section.
OK, so we've found our record, we've displayed it to confirm that it's what there user was looking for, now all we need is that Big Red Button.
Create a form at the bottom of the page.
We're now going to apply the Delete Record Server Behavior to do the dirty deed.
You should hopefully be presented with a dialog box a lot like this one
Select your Connection, the appropriate Table and check that all the
other items are as you'd expect them.
Finally, select a URL to redirect to after the execution.
Save your page, and try viewing your initial 'search' page in a browser
And the result ....
Then after clicking the button ...
Our entry has been removed from the database, and so no longer exists at the top of the list!
Time for another pat on the back!