SqlDataSourceView.DeleteParameters Property

Note: This property is new in the .NET Framework version 2.0.

Gets the parameters collection containing the parameters that are used by the DeleteCommand property.

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

public:
property ParameterCollection^ DeleteParameters {
	ParameterCollection^ get ();
}
/** @property */
public ParameterCollection get_DeleteParameters ()

public function get DeleteParameters () : ParameterCollection

Property Value

A ParameterCollection that contains the parameters used by the DeleteCommand property.

If the DeleteCommand property contains a parameterized SQL query, the DeleteParameters collection contains any Parameter objects that correspond to the parameter placeholders in the SQL string.

Parameter names might be affected by the OldValuesParameterFormatString property; specifically, if the name identifies a primary key, such as a key that is specified using the DataKeyNames property of a data-bound control, or in delete and update scenarios in which the ConflictDetection property is set to the CompareAllValues value and a set of oldValues is passed to the corresponding data method. In this case, the format string is applied to each parameter name in the oldValues collection.

Depending on the ADO.NET provider, the order of the parameters in the DeleteParameters collection might be important. The System.Data.OleDb and System.Data.Odbc providers associate the parameters in the collection according to the order that the parameters appear in the parameterized SQL query. The System.Data.SqlClient provider, which is the default ADO.NET provider for the SqlDataSource control, associates the parameters in the collection by matching the name of the parameter with the placeholder in the SQL query. For more information on parameterized SQL queries and commands, see Using Parameters with the SqlDataSource Control.

The following code example demonstrates how to set the DeleteCommand text to delete an order from the Northwind database. Initially, data is retrieved from the Orders table and displayed in a DropDownList control. You must explicitly declare the DeleteParameters property and call the Delete method when using data-bound controls, such as the DropDownList (unlike controls, such as the GridView and DetailsView, which automatically populate the parameters and call the Delete method on a data source control). In this example, the OnClick event is delegated to the private OnDeleted event handler, which explicitly calls the Delete method of the SqlDataSource control.

No code example is currently available or this language may not be supported.
<%@Page  Language="VJ#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<SCRIPT runat="server">
    private void OnDelete(Object sender, System.EventArgs e)
    {
        SqlDataSource1.Delete();
    } //OnDelete
</SCRIPT>

<HTML>
    <BODY>
        <FORM runat="server">

            <asp:SqlDataSource
                id="SqlDataSource1"
                runat="server"
                ConnectionString="Data Source=localhost;Integrated Security=SSPI;Initial Catalog=Northwind;"
                SelectCommand="SELECT OrderID FROM Orders"
                DeleteCommand="DELETE FROM [Order Details] WHERE OrderID=@OrderID;DELETE FROM Orders WHERE OrderID=@OrderID;">
                <DeleteParameters>
                    <asp:ControlParameter Name="OrderID" ControlId="DropDownList1" PropertyName="SelectedValue" />
                </DeleteParameters>
            </asp:SqlDataSource>

            <asp:DropDownList
                id="DropDownList1"
                runat="server"
                DataTextField="OrderID"
                DataValueField="OrderID"
                DataSourceID="SqlDataSource1">
            </asp:DropDownList>

            <asp:Button
                id="Button1"
                runat="server"
                Text="Delete Order"
                OnClick="OnDelete">
            </asp:Button>

        </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.

.NET Framework

Supported in: 2.0

Community Additions

ADD
Show: