ObjectDataSourceMethodEventArgs.InputParameters Property
Assembly: System.Web (in system.web.dll)
/** @property */ public IOrderedDictionary get_InputParameters ()
public function get InputParameters () : IOrderedDictionary
Property Value
An IDictionary of name/value pairs that represent the business object method parameters and their corresponding values.Parameters can be passed to the business object method by reference or by value. If you use an ObjectDataSourceMethodEventHandler object to handle the Selecting, Updating, Inserting, or Deleting events, you can access and manipulate these parameters using the InputParameters property. Any changes to the parameters in this dictionary will affect which method overload is called for the operation. When the DataObjectTypeName property of the ObjectDataSource control is set, you can modify only the data object properties for the items in this dictionary; you cannot add or remove parameters. For more information, see Delete.
Parameters that are passed by reference are returned in the OutputParameters property of the ObjectDataSourceStatusEventArgs object.
The following code example demonstrates how to use a DropDownList control, TextBox controls, and several ObjectDataSource controls to update data. The DropDownList displays the name of a Northwind Employee, while the TextBox controls are used to enter and update address information. Because the UpdateParameters property contains a ControlParameter object that is bound to the selected value of the DropDownList control, the button that triggers the Update method is only enabled after an employee is selected.
In this example, the NorthwindEmployeeUpdating method is called before the Update method to add the correct parameters and values to the InputParameters collection. You can add the parameters and values dynamically, as demonstrated, or declaratively.
<%@ Register TagPrefix="aspSample" Namespace="Samples.AspNet.JSL" Assembly="Samples.AspNet.JSL" %>
<%@ Page Language="VJ#" %>
<%@ Import namespace="Samples.AspNet.JSL" %>
<Script runat="server">
// Add parameters and initialize the user interface
// only if an employee is selected.
private void Page_Load(Object sender, System.EventArgs e) throws NorthwindDataException
{
// Be sure the text boxes are initialized with
// data from the currently selected employee.
NorthwindEmployee selectedEmployee =
EmployeeLogic.GetEmployee(DropDownList1.get_SelectedValue());
if (selectedEmployee != null) {
AddressBox.set_Text(selectedEmployee.get_Address());
CityBox.set_Text(selectedEmployee.get_City());
PostalCodeBox.set_Text(selectedEmployee.get_PostalCode());
Button1.set_Enabled(true);
}
else {
Button1.set_Enabled(false);
}
} //Page_Load
// Press the button to update.
private void Btn_UpdateEmployee(Object sender, CommandEventArgs e)
{
ObjectDataSource2.Update();
} //Btn_UpdateEmployee
// Dynamically add parameters to the InputParameters collection.
private void NorthwindEmployeeUpdating(Object source,
ObjectDataSourceMethodEventArgs e)
{
// The names of the parameters are the same as
// the variable names for the method that is invoked to
// perform the Update. The InputParameters collection is
// an IDictionary collection of name/value pairs,
// not a ParameterCollection.
e.get_InputParameters().Add("anID", DropDownList1.get_SelectedValue());
e.get_InputParameters().Add("anAddress", AddressBox.get_Text());
e.get_InputParameters().Add("aCity", CityBox.get_Text());
e.get_InputParameters().Add("aPostalCode", PostalCodeBox.get_Text());
} //NorthwindEmployeeUpdating
</Script>
<html>
<head>
<title>ObjectDataSource - VJ# Example</title>
</head>
<body>
<form id="Form1" method="post" runat="server">
<!-- The DropDownList is bound to the first ObjectDataSource. -->
<asp:objectdatasource
id="ObjectDataSource1"
runat="server"
selectmethod="GetAllEmployees"
typename="Samples.AspNet.JSL.EmployeeLogic" />
<p><asp:dropdownlist
id="DropDownList1"
runat="server"
datasourceid="ObjectDataSource1"
datatextfield="FullName"
datavaluefield="EmpID"
autopostback="True" /></p>
<!-- The second ObjectDataSource performs the Update. This
preserves the state of the DropDownList, which otherwise
would rebind when the DataSourceChanged event is
raised as a result of an Update operation. -->
<asp:objectdatasource
id="ObjectDataSource2"
runat="server"
updatemethod="UpdateEmployeeWrapper"
onupdating="NorthwindEmployeeUpdating"
typename="Samples.AspNet.JSL.EmployeeLogic" />
<p><asp:textbox
id="AddressBox"
runat="server" /></p>
<p><asp:textbox
id="CityBox"
runat="server" /></p>
<p><asp:textbox
id="PostalCodeBox"
runat="server" /></p>
<asp:button
id="Button1"
runat="server"
text="Update Employee"
oncommand="Btn_UpdateEmployee" />
</form>
</body>
</html>
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.