Parameter::Name Property


Gets or sets the name of the parameter.

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

property String^ Name {
	String^ get();
	void set(String^ value);

Property Value

Type: System::String^

The name of the parameter. The default value is String::Empty.

Parameter objects are not required to have a name; however, data source controls might use the parameter name to match a Parameter object in a collection with a parameter in a SQL query or business method signature. For example, the SqlDataSource control can use the name of the Parameter object to match a placeholder in a parameterized SQL query. Similarly, the SqlDataSource control can use the name of a Parameter object in the FilterParameters collection to match a placeholder in the FilterExpression property. In some cases, the name is not used and the order in which the Parameter object is added to a ParameterCollection collection is more important. For more information, see Using Parameters with the SqlDataSource Control and Using Parameters with the ObjectDataSource Control.

If the name of the parameter is changed, the OnParameterChanged method is called.

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 code example consists of a TextBox control, a GridView control, the ObjectDataSource control, and a Submit button. By default, the TextBox control is populated with the name of one of the Northwind employees. The GridView control displays information about the employee identified by the name in the TextBox control. To retrieve data on another employee, enter the full name of the employee in the TextBox control and click the button.

The FilterExpression property specifies an expression used to filter the data retrieved by the SelectMethod property. It uses parameter placeholders that are evaluated to the parameters 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 needed.

This code example is part of a larger example provided for the FilterExpression property of the ObjectDataSource class.

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

.NET Framework
Available since 2.0
Return to top