Chapter 17. Using Server Data
The ASP.NET AJAX features introduced thus far all contribute to a considerable savings in development time and effort. Yet, there are more, very powerful features and functionality yet to come.
In this chapter, you’ll learn how to use ASP.NET AJAX to connect to databases and bind data from these sources to page elements. This functionality isn’t limited to simple, static controls like text fields, but lets you bind complex data as well. With ASP.NET AJAX, you can use tables and HTML lists to display data and, as with so many other features we’ve explored, you can create your own custom data source.
In Chapter 16, you were introduced to client control data binding. However, servers were not a part of this discussion. This chapter will expand upon what you learned about data binding, dealing with data from a server. You will write a web service that retrieves data from the data source and return it. You will then use the client ASP.NET AJAX controls and xml-script markup to display that data in HTML.
Using a ListView Control
The best way to display data in ASP.NET AJAX is using the ListView control (in xml-script, the <listView> element). This control can iterate through a list so that the user can view the result—hence, the name of the control.
Within a <listView> xml-script element, you can define two display templates:
- <layoutTemplate>
To specify the layout and appearance of the data
<itemTemplate>To specify the layout for each individual element (item) of ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access