ObjectDataSourceView.SelectParameters Property
Assembly: System.Web (in system.web.dll)
/** @property */ public ParameterCollection get_SelectParameters ()
public function get SelectParameters () : ParameterCollection
Not applicable.
Property Value
A ParameterCollection that contains the parameters used by the method specified by the SelectMethod property.The names and types of the parameters that are contained in the SelectParameters collection must match the names and types of the parameters that are in the method specified by the SelectMethod property signature. When working with data-bound controls that supply parameters, such as GridView and DetailsView, the ObjectDataSource control automatically merges any parameters that are explicitly specified in the collection with those parameters that are provided by the data-bound control. For more information, see ObjectDataSource.SelectMethod.
The following code example demonstrates how to retrieve a single data record using an ObjectDataSource control, and then display the data record in a DetailsView control. The ObjectDataSource retrieves a specific employee record by calling the GetEmployee method of the EmployeeLogic class. The GetEmployee method requires an employee ID parameter. The ObjectDataSource control uses a QueryStringParameter object in its SelectParameters collection to pass an ID to the GetEmployee method.
To view the example implementation of the EmployeeLogic class and the GetEmployee method, see ObjectDataSource.
<%@ Register TagPrefix="aspSample" Namespace="Samples.AspNet.jsl" Assembly="Samples.AspNet.jsl" %>
<%@ Page Language="VJ#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>ObjectDataSource - VJ# Example</title>
</head>
<body>
<form id="Form1" method="post" runat="server">
<asp:detailsview
id="DetailsView1"
runat="server"
datasourceid="ObjectDataSource1">
</asp:detailsview>
<asp:objectdatasource
id="ObjectDataSource1"
runat="server"
selectmethod="GetEmployee"
typename="Samples.AspNet.jsl.EmployeeLogic" >
<selectparameters>
<asp:querystringparameter name="anID" querystringfield="empid" defaultvalue="-1" />
</selectparameters>
</asp:objectdatasource>
</form>
</body>
</html>