Sample Database-Driven Web Application


The chapters that follow get into all the gritty details of the data controls. Before you get lost in the details, however, I want to provide you with a sample of a data-driven web application. I want to provide you with a "real world" application that illustrates what can be built with the data controls.

In this section, a complete Employee Directory application is built, which supports displaying, adding, editing, and deleting employee information. The sample application includes all the necessary form field validation.

One of the amazing things about the ASP.NET 2.0 Framework is how much the new Framework simplifies data access. The sample application consists of a single page that contains very little code. Writing the same application with the ASP.NET 1.x Framework would require pages of code (I won't even mention how much code it would require to write the same application in ASP Classic).

Because the Employee Directory application includes all the required validation code, the page is a little too long to include in the pages of this book. However, it is included on the CD that accompanies this book. Open the page named EmployeeDirectory.aspx.

After you open the EmployeeDirectory.aspx page in your browser, you see a list of employees. This list is rendered by a GridView control (see Figure 8.18).

Figure 8.18. Displaying a list of employees with the GridView control.


Next to each employee, there is a Delete link and a Details link. If you click Delete, the selected employee is deleted from the database. Notice that a client-side confirmation dialog box appears when you click the Delete link (see Figure 8.19). This dialog box is added to each of the Delete links in the grdEmployees_RowCreated() method. This method is called automatically by the GridView control as the GridView creates each row.

Figure 8.19. Deleting employee information.


If you click the Details link, a window appears that displays detailed information for the Employee (see Figure 8.20). The detailed information is rendered by a FormView control. The window that appears is created with an absolutely positioned <div> tag.

Figure 8.20. Displaying employee details.


If you click Edit when viewing a employee's details, you can edit the employee record. The edit form is contained in the FormView control's EditItemTemplate. Each of the form fields is associated with a RequiredFieldValidator control.

Finally, you can add new employees to the directory by clicking the Add Employee button. The form that appears is also rendered by a FormView control (see Figure 8.21).

Figure 8.21. Adding a new employee.


Web Standards Note

The Employee Directory application works great in Internet Explorer 6, FireFox 1.0, and Opera 8.0. The only feature of the application that breaks Web standards is the use of the Drop Shadow filter around the pop-up window. The Drop Shadow effect works only in Internet Explorer.





ASP. NET 2.0 Unleashed
ASP.NET 2.0 Unleashed
ISBN: 0672328232
EAN: 2147483647
Year: 2006
Pages: 276

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net