WindowsDevCenter.com
oreilly.comSafari Books Online.Conferences.

advertisement


AddThis Social Bookmark Button

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

The Review Page

When the user logs in (or clicks on Review/Edit bugs) the Bug review grid is displayed, as shown in Figure 11.

bugreviewgrid
Figure 11. Bug review grid

From here, there are two paths. The first is to choose a bug and click Edit. The job of the Edit button event handler is to stash the BugID into session state (as we saw earlier, the editing page will need this) and then to redirect the user to TBTReportBug.aspx:

protected void BugReviewGrid_RowEditing(object sender, 
    GridViewEditEventArgs e)
{
    Session["Edit"] = 
        BugReviewGrid.DataKeys[e.NewEditIndex].Value.ToString();
    e.Cancel = true;
    Response.Redirect("TBTReportBug.aspx");
}

The first statement indexes into the DataKeys collection of the grid to find the key for the currently selected row (the row aligned with the Edit button) and retrieves its value, storing it (the BugID) into the "Edit" value in Session state. The second statement sets the Cancel property of the GridViewEditEventArgs object to true, indicating that no further editing action is required (turning off in-place editing). The third statement transfers control to the TBTReportBug.aspx page.

Clicking the Details button will bring up a DetailsView page. This happens automatically, with no code! You accomplish this tiny miracle by dragging on the DetailsView object and creating a new SqlDataSource object to go with it. The Select statement for the new data source has a parameter (@BugID), which you define, using the wizard, as being set by a control--specifically, the BugReviewGrid (see Figure 12).

parametersource
Figure 12. Control parameter source

That's all it takes. When the Details button is clicked (which is the select button in disguise), the BugDetailDataSource recognizes that there is now a selected item and shows the DetailsView.

I added a CommandButton labeled History to the DetailsView, as shown in Figure 13.

HistoryButton
Figure 13. History button

Note that the Details view (circled) adds only two other fields (the full description and the notes) because all the remaining fields are already displayed in the grid.

Because the History button does not select a row, an event handler must be written to display the grid showing the history of the selected row:

protected void BugDetailsView_ItemCommand(object sender,
    DetailsViewCommandEventArgs e)
{
    BugHistoryGrid.DataBind();
    BugHistoryGrid.Visible = true;
}

Calling DataBind on the BugHistoryGrid causes the Select statement to be called on its associated DataSource:

SELECT [ModifiedBy], [ShortDescription], [TimeStamp], [BugHistoryID], 
sev.text as Severity, stat.text as Status, [Owner], bh.BugID FROM [BugHistories] bh
join severities sev on sev.SeverityID = bh.Severity
join statuses stat on statiStics = bh.Status
WHERE ([BugID] = @BugID) ORDER BY [BugHistoryID] DESC

The BugID is supplied by the BugReviewGrid using a ControlParameter source (as we've seen before). Finally, this grid itself has Details buttons that call up the details for any of the BugHistory entries (see Figure 14).

extendedDetails
Figure 14. Extended details

In short, what you are seeing here is the details for the second bug (Records are being corrupted) along with its history (the original entry, as well as one revision) and the details for the revision.

Ever So Much More To Do

There's plenty more to do (if nothing else, the grids need labels). As noted earlier, I certainly want to be able to see only my bugs and I'd like to sort them in complex ways (e.g., by Severity and then by age). However, even this rough-and-ready version is quite usable for tracking bugs in a small project.

The complete source for this application is available on my website ; just click on Books and then on Articles.

Jesse Liberty is a senior program manager for Microsoft Silverlight where he is responsible for the creation of tutorials, videos and other content to facilitate the learning and use of Silverlight. Jesse is well known in the industry in part because of his many bestselling books, including O'Reilly Media's Programming .NET 3.5, Programming C# 3.0, Learning ASP.NET with AJAX and the soon to be published Programming Silverlight.


Return to the Windows DevCenter.