System.Web.UI.WebControls.SqlDataSourceView Class

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

See Also: SqlDataSourceView Members

Syntax

public class SqlDataSourceView : System.Web.UI.DataSourceView, System.Web.UI.IStateManager

Remarks

The System.Web.UI.WebControls.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 System.Web.UI.WebControls.SqlDataSourceView class extends the System.Web.UI.DataSourceView class, defines the capabilities of the System.Web.UI.WebControls.SqlDataSource control with which it is associated, and implements the basic data functionality for the data source control. The System.Web.UI.WebControls.SqlDataSourceView class implements the data functionality for the System.Web.UI.WebControls.SqlDataSource control, including the erload:System.Web.UI.WebControls.SqlDataSourceView.Select, erload:System.Web.UI.WebControls.SqlDataSourceView.Update, erload:System.Web.UI.WebControls.SqlDataSourceView.Insert, and erload:System.Web.UI.WebControls.SqlDataSourceView.Delete operations, sorting, filtering, and managing settings that are kept in view state.

Although the System.Web.UI.WebControls.SqlDataSourceView object is not directly exposed to page developers by the System.Web.UI.WebControls.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 erload:System.Web.UI.WebControls.SqlDataSourceView.Select method, which retrieves an IEnumerable collection of data items. The System.Web.UI.WebControls.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 System.Web.UI.WebControls.SqlDataSourceView and exposed directly by its System.Web.UI.WebControls.SqlDataSource control to page developers and other callers:

The System.Web.UI.WebControls.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 System.Web.UI.WebControls.GridView and System.Web.UI.WebControls.DetailsView, can be configured to perform updates automatically using the System.Web.UI.WebControls.SqlDataSourceView, while other controls cannot. The following update methods, properties, and events are implemented by the System.Web.UI.WebControls.SqlDataSourceView and exposed directly by its System.Web.UI.WebControls.SqlDataSource control to page developers and other callers:

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

The System.Web.UI.WebControls.SqlDataSourceView object also supports deleting data from a relational database. As with other commands, the SQL commands that are specified in the SqlDataSourceView.DeleteCommand property can be parameterized for greater flexibility and security. Data-bound controls, such as the System.Web.UI.WebControls.GridView and System.Web.UI.WebControls.DetailsView, can be configured to perform deletes automatically using the System.Web.UI.WebControls.SqlDataSourceView, while other controls cannot. The following delete methods, properties, and events are implemented by the System.Web.UI.WebControls.SqlDataSourceView and exposed directly by its System.Web.UI.WebControls.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 SqlDataSourceView.SelectCommand property on every page load, you can use the SqlDataSourceView.FilterExpression and SqlDataSourceView.FilterParameters properties to apply dynamic filtering to data retrieval. These properties are implemented by the System.Web.UI.WebControls.SqlDataSourceView and exposed directly by its System.Web.UI.WebControls.SqlDataSource control to data-bound controls and other callers.

You can sort the data that you retrieve with the System.Web.UI.WebControls.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 System.Web.UI.WebControls.SqlDataSourceView by setting the System.Web.UI.DataSourceSelectArguments.SortExpression property of the System.Web.UI.DataSourceSelectArguments object that is passed to the SqlDataSourceView.Select(System.Web.UI.DataSourceSelectArguments) method. The syntax for the System.Web.UI.DataSourceSelectArguments.SortExpression property is the same as the syntax for a System.Data.DataView.Sort property. If you use a stored procedure to retrieve data, you can also use the SqlDataSourceView.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 System.Web.UI.WebControls.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 System.Web.UI.WebControls.SqlDataSourceView implements the System.Web.UI.IStateManager interface and uses view state to track its state across page requests. Implementations of the SqlDataSourceView.IsTrackingViewState and property and the SqlDataSourceView.LoadViewState(object), SqlDataSourceView.SaveViewState, and SqlDataSourceView.TrackViewState methods are provided to enable view state tracking for the control. For more information, see ASP.NET State Management Overview.

Requirements

Namespace: System.Web.UI.WebControls
Assembly: System.Web (in System.Web.dll)
Assembly Versions: 2.0.0.0
Since: .NET 2.0