Deleting an entry from your "Recent Updates" List

By now I'm sure you're convinced that Dreamweaver MX 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.

  1. Find that pesky record
  2. 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

The easiest way to choose a record to edit is often just to list them on a page, and stick a 'delete' link next to each row. This is also handy, because it will allow us to use the same page for our 'edit' process later on. In a way, what we are creating here is a generate control center for making changes to our site.

First we need to create a page to list our records. As these records are tabular data, I'm going to put them in an HTML table.

As you can see, I've created a table with a header row and a row for the data, which I've filled out with some placeholders. The next thing to do is to create a recordset, just like we did with the homepage.

From the Bindings panel, choose Recordset.

Again, just as we did with the homepage, apply your data from the Bindings panel onto the page using the Insert button.

Now, this display method is going to work well for short news items, but as soon as you introduce longer items into the mix, this table is going to become long and unmanageable. To combat this, we'll set the newsText field to only display the first, say, 50 characters.

Select the {rsNews.newsText} placeholder, right click and select Edit Tag Code...

As you can see, I've modified the code to read:

<%=left(rsNews.Fields.Item("newsText").Value, 50)%>

The 'left' function used here, says to use a number of characters from the left of the data. We've given it a value of 50.

The next thing to do is to wire up that Delete button. This is going to be a normal link to a delete page, but will also pass the newsID number at the end of the URL. More on that in a moment. The first step is to create a new, empty delete page to link the button to.

Next, highlight your Delete text and click the yellow folder icon in the Property Inspector to create a link. Browse to your new delete file.

Next, click the Parameters button, and add a new parameter called "id".

To set the value, click the yellow lightening bold icon to make the Dynamic Data dialog appear.

Select newsID, and click OK. You should then see the Value filled out for your "id" parameter.

Click OK and OK, and your link is set. What this has done is created a link with a query string. This is a set of name and value pairs that can be added on to a URL after a query character '?'. Instead of linking to this URL:


We're actually linking to it like this:


where {newsID} is the ID of the current record - straight out of our database. The query string can be picked up again in the delete page, as we'll see in stage 2.

Back in the page, apply a Repeat Region server behavior to your data table row so that all records are displayed.

Once applied, the repeat region can be seen in the page. My page looks something like this:

Time to move on to Stage 2 »