Export (0) Print
Expand All

ObjectDataSourceView.FilterParameters Property

Gets a collection of parameters that are associated with any parameter placeholders that are in the FilterExpression string.

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

member FilterParameters : ParameterCollection with get

Property Value

Type: System.Web.UI.WebControls.ParameterCollection
A ParameterCollection that contains a set of parameters associated with any parameter placeholders found in the FilterExpression property.

ExceptionCondition
NotSupportedException

The FilterExpression property was set and the Select method does not return a DataSet.

The ObjectDataSource control supports filtering data only when the Select method returns a DataSet, DataTable, or DataView object.

The parameters in the FilterParameters collection are associated with any parameters that are specified in the FilterExpression property. The parameter placeholders that are specified in the FilterExpression property are matched to parameter objects in the FilterParameters collection when the method specified by the SelectMethod property is called.

This section contains two code examples. The first code example demonstrates how to display filtered data using an ObjectDataSource control to retrieve data from a middle-tier business object and a GridView control to display the results. The second code example provides an example of the middle-tier business object that is used in the first code example.

The following code example demonstrates how to display filtered data using an ObjectDataSource control to retrieve data from a middle-tier business object and a GridView control to display the results. The ObjectDataSource control can filter data only when the method that retrieves the data retrieves it as a DataSet object. For this reason, the SelectMethod property identifies a business object method that retrieves data as a DataSet.

The code example consists of a TextBox, a GridView control, the ObjectDataSource control, and a Submit button. By default, the TextBox is populated with the name of one of the Northwind Traders employees. The GridView displays information about the employee that is identified by the name in the TextBox. To retrieve data on another employee, in the TextBox, enter the full name of the employee, and then click the Submit button.

The FilterExpression property specifies an expression that is used to filter the data that is retrieved by the method specified by the SelectMethod property. It uses parameter placeholders that are evaluated to the parameters that are contained in the FilterParameters collection. In this example, the parameter placeholder is bounded by single quotation marks because the type of the parameter is a string type that might contain spaces. If the type of the parameter is a numeric or date type, bounding quotation marks are not required. The FilterParameters collection contains one parameter, a FormParameter that is bound to the TextBox control.

No code example is currently available or this language may not be supported.

The following code example provides an example of a middle-tier business object that the preceding code example uses. The code example consists of two basic classes:

  • The EmployeeLogic class, which is a class that encapsulates business logic.

  • The NorthwindEmployee class, which is a model class that contains only the basic functionality that is required to load and persist data from the data tier.

For simplicity, the EmployeeLogic class creates a static set of data, rather than retrieving the data from a data tier. It is also helpful for this example, because the sample relies on you to provide the full name of a Northwind Traders employee to demonstrate filtering.

For a complete working example, you must compile and use these classes with the Web Forms page code examples that are provided.

No code example is currently available or this language may not be supported.

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0
Show:
© 2015 Microsoft