Export (0) Print
Expand All
0 out of 2 rated this helpful - Rate this topic

SqlDataSourceView Class

Note: This class is new in the .NET Framework version 2.0.

Supports the SqlDataSource control and provides an interface for data-bound controls to perform SQL data operations against relational databases.

Namespace: System.Web.UI.WebControls
Assembly: System.Web (in system.web.dll)

public class SqlDataSourceView : DataSourceView, IStateManager
public class SqlDataSourceView extends DataSourceView implements IStateManager
public class SqlDataSourceView extends DataSourceView implements IStateManager

The SqlDataSourceView class is intended primarily to be used by data-bound controls, and not as a programmable object in page code.

ASP.NET data source controls contain one or more lists of data, represented by data source view objects. The SqlDataSourceView class extends the DataSourceView class, defines the capabilities of the SqlDataSource control with which it is associated, and implements the basic data functionality for the data source control. The SqlDataSourceView class implements the data functionality for the SqlDataSource control, including the Select, Update, Insert, and Delete operations, sorting, filtering, and managing settings that are kept in view state.

Although the SqlDataSourceView object is not directly exposed to page developers by the SqlDataSource control, many of its properties are. The most basic operation that a data source view performs is data retrieval from the underlying database using the Select method, which retrieves an IEnumerable collection of data items. The SqlDataSourceView class implements data retrieval from relational databases using SQL queries. The SQL queries can be parameterized for greater flexibility and security. The following data retrieval methods, properties, and events are implemented by the SqlDataSourceView and exposed directly by its SqlDataSource control to page developers and other callers:

The SqlDataSourceView object supports updating data in a relational database using SQL commands. The SQL commands can be parameterized for greater flexibility and security. Data-bound controls, such as the GridView and DetailsView, can be configured to perform updates automatically using the SqlDataSourceView, while other controls cannot. The following update methods, properties, and events are implemented by the SqlDataSourceView and exposed directly by its SqlDataSource control to page developers and other callers:

The SqlDataSourceView supports inserting new rows of data into a relational database. The SQL commands that are specified in the InsertCommand property can be parameterized for greater flexibility and security. Data-bound controls, such as the GridView and DetailsView, can be configured to perform inserts automatically using the SqlDataSourceView, while other controls cannot. The following insert methods, properties, and events are implemented by the SqlDataSourceView and exposed directly by its SqlDataSource control to page developers and other callers:

The SqlDataSourceView object also supports deleting data from a relational database. As with other commands, the SQL commands that are specified in the DeleteCommand property can be parameterized for greater flexibility and security. Data-bound controls, such as the GridView and DetailsView, can be configured to perform deletes automatically using the SqlDataSourceView, while other controls cannot. The following delete methods, properties, and events are implemented by the SqlDataSourceView and exposed directly by its SqlDataSource control to page developers and other callers:

Data retrieval is more powerful when the clause that is used to filter the data during data retrieval is dynamic. In other words, an SQL query with a static WHERE clause is not as flexible and powerful as an SQL query where the values in the WHERE clause are bound to values that can change, such as values that are displayed in controls on a Web Forms page. Instead of rebuilding an SQL query and setting the SelectCommand property on every page load, you can use the FilterExpression and FilterParameters properties to apply dynamic filtering to data retrieval. These properties are implemented by the SqlDataSourceView and exposed directly by its SqlDataSource control to data-bound controls and other callers.

You can sort the data that you retrieve with the SqlDataSource control by adding an ORDER BY clause, which causes the database to perform the ordering for you when you retrieve data or by ordering the data in memory after it is retrieved. You can supply a sorting expression to the SqlDataSourceView by setting the SortExpression property of the DataSourceSelectArguments object that is passed to the Select method. The syntax for the SortExpression property is the same as the syntax for a DataView.Sort property. If you use a stored procedure to retrieve data, you can also use the SortParameterName property to specify a parameter that is used specifically for sorting the results of a stored procedure call.

When more than one user can change the database concurrently, there is the potential for concurrency conflict. The SqlDataSource control has controls concurrency through the SqlDataSource.ConflictDetection property. The functionality is implemented in the SqlDataSourceView.ConflictDetection property.

Like many other Web server controls, the SqlDataSourceView implements the IStateManager interface and uses view state to track its state across page requests. Implementations of the IsTrackingViewState and property and the LoadViewState, SaveViewState, and TrackViewState methods are provided to enable view state tracking for the control. For more information, see ASP.NET State Management Overview.

System.Object
   System.Web.UI.DataSourceView
    System.Web.UI.WebControls.SqlDataSourceView
       System.Web.UI.WebControls.AccessDataSourceView
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.