ASP.NET 1.1 along with VS.NET made the life of Web developers much easier
thanks to the rich data environment it had. The System.Data namespace along with
the associated managed providers for SQL Server, Oracle, OLEDB and ODBC made
programming and using databases a dream. Almost all controls that could be
placed on the page, such as Textbox and DropDownList, were data aware. Inclusion
of rich data controls, such as the DataGrid and DataList, were a boon for
developers.Â
Developers can now be even happier, since a new and enhanced data model comes
in ASP.NET 2.0. In this model, apart from the standard namespaces, you have two
types of controls: Data Source Controls and Data Bound Controls.
Data Source Controls are non-UI controls, that is, they do not have a visible
user interface and are not rendered on the client. Instead, they simply point to
(reference) different backend data sources, which could be a database, XML file,
a Web service or a business layer object. These controls provide all the data
capabilities, such as sorting, filtering, paging and insert/update/
deleting.
|
Data Bound Controls, on the other hand, are the frontend controls. These
controls get rendered on the client browser. The Data Bound Controls bind to a
Data Source Control to retrieve data to display. In many cases, this can even
happen automatically, where a Data Bound Control of a specific type can detect
whether a Data Source Control of the type it expects, is already present and can
bind to it without developer intervention (of course, one downside of such
intelligent control is that it makes developers lazy.)
So what do these controls look like? A Data Source Control could look
something like this, if your backend is SQL Server.
In case your backend is an XML file, then it would look something like
this.
/>
|
By default there are six data sources: SqlDataSource (uses not only SQL
Server, but any database using the managed providers), ObjectDataSource (uses
any business object), AccessDataSource, DataSetDataSource, SiteMapDataSource
(uses an XML file to represent the website's structure) and XMLDataSource (for
any other XML file).Â
These Data Source Controls are intelligent enough to bind to the controls at
the appropriate time in the page lifecycle. You can, of course, very easily
extend and handle the controls events. Not just that, you can also quite easily
create your own Data Source Controls if the default ones don't 'wing'
it.Â
The Data Bound Controls are the more familiar ones. The good, old
DataGrid continues to exist. However, a much more flexible and powerful new
control, GridView control, offers everything that the DataGrid does and more.
Other new controls that come with VS.NET 2005 are: the DetailsView, TreeView and
the Menu. Each of these, as well as old favorites, such as the DropDownList and
DataList are completely data source aware and can use any of the Data Source
Controls implicitly.
|
This allows a page developer to use the capabilities of the Data Source
Controls from the new data bound controls quite easily. For instance, you no
longer have to write even the three to four lines of code that you needed to,
for enabling sorting or paging for a DataGrid. Using a SqlDataSource and
GridView you can enable a few options and both the controls work in tandem to
provide you the functionality.
The new controls do not just get relational data (as in from an RDBMS). They
can also work with hierarchical data. The SiteMapDataSource and the
XMLDataSource are ones that can use this sort of data. The TreeView and Menu
controls are the ones that can use these sort of hierarchical data and display
them natively.Â
In the next article, we'll start looking at samples of how you can start using these
new capabilities of ASP.NET in your Web applications. We will use the beta of
VS.NET 2005 or the new express Visual Web Developer beta-a lite version of
VS.NET that is suitable for hobbyists, students and small-scale developers to do
this.Â
Source: PCQuest
/ciol/media/agency_attachments/c0E28gS06GM3VmrXNw5G.png)
Follow Us/ciol/media/post_attachments/7a105ee69e1d0d9c06c581f39ec386d468facefabf9da666cc16ea459647bfe7.jpeg)
/ciol/media/post_attachments/edff18e8ddd33f75f79fbe8cda8df5cdd36a4c33fe2dcd19514356f6990ef058.jpeg)