Flylib.com

Books Software

 
 
 

Deployment and Customization

Deployment and Customization

The deployment of this application is straightforward. First, copy all the Web files into a folder in the Web root directory. Next, attach a copy of the SQL database to the database server you wish to access. Finally, change the ConnectionString in the appSettings section of the web.config file to one that will allow access to the database.

This application has a lot of potential for further customizations. Adding a multiuser scheduling feature that would allow a best time/date to be automatically chosen would be my favorite, but there are many other possible features that can be added.

Summary

In this chapter, you've learned how to build an entire scheduling application. One of the main things we touched on was databinding to a control with custom databinding. This application also uses SQL Server effectively by accessing stored procedures.

After reading this chapter, you should be able to write custom controls that are derived from the standard ASP.NET server controls. This will give you flexibility as you design and write your own controls based on the standard controls.

Chapter 6. The Microsoft Forum Application

In This Chapter:

  • Using Embedded Server Controls in Iterative Databound Controls

  • The Database

  • The Repeater Demo

  • The DataList Demo

  • The DataGrid Demo

Microsoft went the extra mile to provide some great applications that are examples of how to get the most out of the .NET Framework, and especially ASP.NET. This chapter shows the Microsoft Forum application, and then talks about one specific technique that's used—how to use embedded server controls in iterative databound controls.

The Microsoft Forum application is freely available from www.ASP.net, where you can follow the links to Source Projects, and then to ASP.NET Forums. I have the application installed on www.ASPNET-Solutions.com, as you can see in Figure 6.1.

Figure 6.1. The ASP.NET Forum Application Offers a Fantastic Way for Users to Communicate.

graphics/06fig01.jpg

Using Embedded Server Controls in Iterative Databound Controls

In this section, I'll show you how to get more functionality from iterative databound controls such as Repeaters, DataLists, and DataGrids. With the extra functionality comes a richer user interface, which will ultimately yield a better application. Applications that have smooth user interfaces almost always work better because users more easily grasp their functionality.

To pull this enhancement off, server controls such as Labels, CheckBoxes, and DropDownLists can be embedded into iterative databound controls. Getting access to the embedded controls is easy, thus making the iterative databound controls very flexible.

The scenario is this: You've convinced your boss to let you develop the next Web application with ASP.NET. He's reluctant, but one of the selling points is the iterative databound controls, including Repeaters, DataLists, and DataGrids. These three databound controls differ from other databound controls such as the DropDownList or ListBox because they're iterative. Iterative controls loop through a data source to which they're bound and apply HTML templates to each row of data.

OK; so three weeks have passed, and your boss comes by to see the work in progress. One of the pages has a Repeater object that's been bound to a recordset that was retrieved from the database. The application looks great, and he's really impressed with the small amount of code it took to get the result. He asks for a change, though. You need to be able to select each row with a checkbox so that users can select any number of items for processing.

You get busy and scour the Repeater documentation. There must be something about checkboxes. But hours of research are fruitless, and you throw up your hands in despair. Maybe a Repeater wasn't the object type you should have used. You take a look at the DataList and DataGrid objects, hoping to find the solution, but no such luck. No checkboxes are built into the iterative databound controls.

Hold on, though; there is hope. Server controls such as CheckBoxes, Labels, and TextBoxes can all be embedded within ASP.NET iterative databound controls. With the right approach, the Repeater in the already-developed ASP.NET application can be easily changed to give users the capability to select the items in the list. This section talks about embedding server controls in iterative databound controls, and shows some example programs that'll help you understand.

ASP.NET iterative databound controls give you an easy way to display lists of data from a data source. They also offer flexibility because you can add server controls such as Labels and CheckBoxes to the declarative constructs, such as ItemTemplates, that go in the .aspx file. The section is broken into three parts : a Repeater demo, a DataList demo, and a DataGrid demo.

For each demo, I'll talk about the declaration of the objects that reside in the .aspx file. This declaration includes things such as ItemTemplates and Columns.

For each demo, I'll also go through the code that's behind it. We'll rely heavily on the FindControl() method. This method obtains object references to the server controls that we want to access.

All code snippets are presented in C# and VB. The complete demo project can be downloaded as either a C# or a VB project.