Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Build Your Own ASP.NET 2.0 Web Site Using CSharp And VB (2006) [eng].pdf
Скачиваний:
74
Добавлен:
16.08.2013
Размер:
15.69 Mб
Скачать

Chapter 10: Displaying Content Using Data Lists

FooterStyle

customizes the appearance of the DataList’s footer

SelectedItemStyle

customizes the appearance of a selected item within the DataList

EditItemStyle

customizes the appearance of the DataList when in edit mode

In the next chapter, you’ll learn how to use CSS styles and control skins to facilitate a more professional approach to styling your data controls. Until then, enjoy the benefits of having a modern-looking, functional employee directory!

Summary

As you’ve seen, DataLists provide flexibility and power in terms of presenting database data dynamically within the browser. In this chapter, you learned how to bind your data to DataLists, and how to customize their appearance using templates and styles. You also learned how to edit data in your DataList control, and how to access controls located in the DataList templates.

The next chapter will introduce you to two new and more powerful controls:

GridView and DetailsView.

426

11

Managing Content Using Grid

 

 

View and Details View

In the previous chapters, you learned some of the important concepts surrounding data access and presentation. You learned that when connecting to a database, we have to establish a connection using the SqlConnection class. You also learned that in order to retrieve data from the database table, we must write an SQL statement within a command using the SqlCommand class. You discovered that we use the SqlDataReader class to place the database records into a virtual container of some sort. Finally, you learned that presenting the data within the SqlDataReader was simply a matter of binding the SqlDataReader to a data control such as the Repeater or DataList controls.

The Repeater and DataList controls offer flexibility in the sense that their templates can easily be customized with inline HTML, in conjunction with code render blocks, to display the contents in a clean and neatly formatted manner. So far, these two controls have been great! They certainly have their place, and I’m not about to discourage you from using them. However, these controls do remind ASP developers a little too much of the bad old days when we had to write our HTML table and table row tags in While loops. Within those table row tags, we also had to add code render blocks to display the contents of the data source. As you’ve probably noticed, the Repeater control isn’t much different from the techniques we were forced to use in those bad old days. HTML table row tags still have to be added within the <HeaderTemplate>, <ItemTemplate>, and <FooterTemplate> tags, and code render blocks must still be used within