28 CHAPTER 1 ?– SERVER CONTROL BASICS
The data in each row of the DataSet is available via the Container.DataItem reference available
for use inside the template content. A string index name something like ???Title??? is used
to grab a particular column for display. Although using code-behind over inline script as much
as possible is preferable, DataBinder.Eval() is a late-bound formatting method that we use to
keep from having to do ugly casts to satisfy the strongly typed nature of C# and ASP.NET. Interestingly,
the Repeater control is the only list-based control that allows HTML formatting to
span across the templates. Figure 1-13 shows the output from this list controls demonstration.
Figure 1-13. Output from the list controls web form
Rich Controls
The list controls are nice for working with data sources and building templated user interfaces,
but sometimes, a web project needs more help from a control when building dauntingly complex
pieces of HTML content. This is the domain of rich controls, such as the Calendar and AdRotator,
in System.Web.UI.WebControls. They make hard-to-generate HTML appear easy, as they require
little in the way of development to generate significant HTML output.
CHAPTER 1 ?– SERVER CONTROL BASICS 29
A Rich Controls Demonstration
This rich controls web form demonstration shows the Calendar control in action.
Pages:
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81