oreilly.comSafari Books Online.Conferences.


AddThis Social Bookmark Button

Build a Web-Based Bug Tracking App, Part 2
Pages: 1, 2, 3, 4

Cancelling an Edit or New Bug

In the previous version, I never implemented the Cancel button in TBTReportBug.aspx. In this version, we'll do two things: we'll stash away a message to be displayed in the Review page, and we'll redirect to that page.

protected void btnCancel_Click(object sender, EventArgs e)
    Session["Message"] = "No action taken";

When you load the Review page, you'll check to see if this session variable exists; if so you'll display it in the label and then delete it.

lblMsg.Text = Session["Message"] != null ? 
    Session["Message"].ToString() : String.Empty;

Note: this uses C#'s ternary operator (?:) and you can read this statement as "if the value in Session Message is not null, assign that value as a string to the label's text property; otherwise, set that property to the empty string."

Logging In and Out

To facilitate testing let's add a LoginStatus control to the master page, using only the LogOut link, as the control need not even be visible for users who are not logged in (done properly, you can't get to any of the other pages if you are not logged in). Drag a LoginStatus control next to the title, and set its LogoutPageURL to the Welcome page, its LogoutAction property to Redirect and its LogoutText property to "Log out." While we are at it, we can set the LoginText property to blank.

By assigning one user to the QA role, and other users to other roles (e.g., developer) we can edit bugs and quickly prove that only QA members can close a bug.

Marking Show-Stopper Bugs In Red

To fulfill the fifth and final requirement (marking show-stopper bugs in red), we need to create a method to handle the event raised when each data item is added to the grid. Click the Grid, click the lightning bolt, and then double-click in the RowDataBound event.

The event handler provided has a derived EventArgs object of the type GridViewRowEventArgs, which provides access both to the row in the grid and to the underlying data (e.Row.DataItem). In our case, however, we can simply access the row in the grid, find the sixth cell (which contains the status) and see if it meets our criteria. If so, we draw in bold and red:

protected void BugReviewGrid_RowDataBound(object sender, 
    GridViewRowEventArgs e)
    if (e.Row.RowType == DataControlRowType.DataRow)
        TableCell cell = e.Row.Cells[5];
        if (cell.Text.ToUpper() == "SHOW STOPPER")
            cell.Font.Bold = true;
            cell.ForeColor = System.Drawing.Color.Red;

The result is shown in Figure 4.

Figure 4. Show stopper in red

This is a very effective way to find your most pressing bugs, and can be generalized to use color for many purposes in your application.

Pages: 1, 2, 3, 4

Next Pagearrow