Chapter 2. Binding Data to the Data Controls

IN THIS CHAPTER

  • Specifying a DataSource

  • The Ins and Outs of the DataBind() Method

  • Building a Class that Implements IEnumerable

  • On the Web

In the previous chapter we examined the three data Web controls at a very high level. We looked at the distinctions among the controls, their various advantages and disadvantages, and studied simple code examples for each control. The purpose of the data Web controls is to display data on an ASP.NET Web page, while attempting to keep the source code and HTML presentation markup as separate as possible.

The standard way of rendering one of these controls is to first grab some data from a data store. An example would be filling a DataSet with the results of a SQL query against a Microsoft Access database. As we saw in the previous chapter, once the data has been populated in a DataSet, or in another appropriate object, we bound the data to the control by assigning the DataSet to the control's DataSource property. The last step involved was to call the control's DataBind() method.

Up to this point, we've only set the DataSource property to a DataSet object. However, other types of objects can be assigned to the DataSource, and hence rendered in a data Web control. We'll examine the criteria an object must fit for it to be assignable to the DataSource property. In this chapter we'll also take a closer look at the DataBind() method, and what's happening behind the scenes when this method is called.



ASP. NET Data Web Controls Kick Start
ASP.NET Data Web Controls Kick Start
ISBN: 0672325012
EAN: 2147483647
Year: 2002
Pages: 111

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