Performing Data Access

What's New in 2.0

  • Data Source Controls //数据源控件- ASP.NET 2.0 introduces declarative data source controls //数据源控件that expose //暴露,揭露 data from a backend store, such as //例如,像a SQL database, middle-tier business object, or XML file, to data-bound UI controls on a page. Data source controls also expose//暴露,揭露 capabilities //能力such as sorting//排序, paging, caching//缓存, updating, inserting and deleting data that UI controls can automatically take advantage of //有...优势without requiring code//不需用代码.

  • New Data-bound Controls //数据绑定控件- In addition to//除了 the data-bound controls in ASP.NET v1.x, ASP.NET includes new data-bound UI controls such as GridView, DetailsView, FormView, TreeView, and Menu, which can be customized //定制,个性化to display data in a variety of formats//各种各样的形式. The GridView, DetailsView, and FormView controls can also automatically take advantage of//利用 data source capabilities, making is easy to add sorting//排序, paging//分页, and update//修改 operations//操作 to data-driven//数据驱动 pages.

  • Data Control Parameters - Data sources can accept input parameters//参数 from a variety of sources using the new data control parameter objects //参数对像in ASP.NET 2.0. These parameter objects//参数对像 allow you to easily supply server control property values//服务器控件属性值, session, application, cookie and querystring //查询字符串fields, and user profile properties //用户基本资料属性to parameterized data operations//参数化的数据操作. Using these parameters enables filtering//过滤 and master-details scenarios //情节,剧本with little or no custom code//客户端代码.

  • Improved Data Binding Syntax//语法 - The DataBinder.Eval data binding syntax in ASP.NET has been simplified for the common scenario of binding a control in a data-bound template//数据绑定模板. It is also possible to associate a two-way data binding with //与....联系在一起 control properties//控件属性 in a template, to allow values to be automatically passed to a data source //数据源update, insert, or delete operation. For hierarchical //分层的,体系的XML data, ASP.NET 2.0 also includes an XPath-based data binding syntax//语法.

  • Local File Databases Using SQL Express - For ease of development, ASP.NET 2.0 now supports the ability to connect to a SQL Express database as a local file//本地文件 in the application//在应用程序中, eliminating //消除,取消the need to provision //定位the database to a server just to perform development work//开发工作. Of course, you can still connect to server-based //基于服务的SQL databases as well.
This section //这一节describes these and other data access features//其他数据访问特征 in ASP.NET 2.0.


Nearly every dynamic web application//几乎每一个动态网络程序 performs some kind of data access, and fortunately ASP.NET 2.0 makes this incredibly //难以置信地easy to do. Unlike ASP.NET 1.0, which required developers to write custom code //客户端代码in order retrieve//取回,恢复 and bind data to server controls, ASP.NET 2.0 enables a declarative//声明式的 solution //解决方法for data binding which requires no code at all for the most common data scenarios//情景,剧情, such as:
  • Selecting and displaying data
  • Sorting, Paging and Caching Data
  • Updating, Inserting and Deleting Data
  • Filtering or Master-Details//详细视图 Using Parameters
ASP.NET 2.0 introduces two types of server controls that participate //参加,分享,参与in this declarative//声明式 data binding model. These two types of data controls handle the complexity //复杂性of the stateless //直译:没有国家的Web model for data scenarios//?, so developers don't need to understand page request lifecycle//生命周期 events //?just to perform data binding. Another benefit of this control-based//基于控件的 model is that it can be easily extended //扩展to support additional data access storage providers.

Data Source Controls

Data source controls//数据源控件 have no rendering//表现,描写,<就是不可见的>, but instead represent//表现,表示 a particular backend data store, for example a database, business object, XML file, or XML Web Service. Data source controls also enable rich capabilities //丰富的功能 over data - such as sorting//排序, paging, filtering, updating, deleting, and inserting - that data-bound UI controls can automatically use. ASP.NET includes the following server controls out-of-the-box:

Name Description
SqlDataSource Enables binding to a SQL database represented by an ADO.NET provider, such as Microsoft™ SQL Server, OLEDB, ODBC, or Oracle.
ObjectDataSource Enables binding to a middle-tier object such as a data access layer or business component.
AccessDataSource Enables binding to a Microsoft™ Access (Jet) database.
SiteMapDataSource Enables binding to the hierarchy //等级制度exposed //暴露,展示by an ASP.NET 2.0 site navigation //导航provider.
XmlDataSource Enables binding to an XML file or document.

Data-bound Controls//数据绑定控件

Data-bound controls//数据绑定控件 are UI controls that render data //显示数据as markup to the requesting client device//发出请求的客户端设备 or browser. A data-bound control can auto-bind to data exposed//暴露 from a data source and will fetch//抓取 data at the appropriate time in the page request lifecycle//页面请求生命周期中. These controls can optionally//可选择的 take advantage of//利用 data source capabilities //功能such as sorting, paging, filtering, updating, deleting, and inserting. A data-bound control connects to //连接a data source control through its DataSourceID property. You may be familiar with //熟悉some of the data-bound controls in ASP.NET v1.x, such as DataGrid, DataList, Repeater, and list controls like DropDownList. ASP.NET 2.0 contains several new data-bound controls //数据据绑定控件as well, such as:

Name Description
GridView Renders data in a grid format. This control is an evolution of the DataGrid control, and can automatically take advantage of data source capabilities.
DetailsView Renders a single data item in a table of label/value pairs, similar to the form view in Microsoft™ Access. This control can also automatically take advantage of data source capabilities.
FormView Renders a single data item at a time in a form defined by a custom template. Renders a single data item in a table of label/value pairs, similar to the form view in Microsoft™ Access. This control can also automatically take advantage of //利用data source capabilities.
TreeView Renders data in a hierarchical//有层次结构的 tree view of expandable nodes.
Menu Renders data in a hierarchical //有层次结构的dynamic menu (including flyouts).

This section //章节demonstrates //显示these and other new data features in ASP.NET 2.0.

posted on 2007-04-26 08:21  改变热爱  阅读(170)  评论(0)    收藏  举报

导航