Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
SortParameterName Property

ObjectDataSource.SortParameterName Property

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

Gets or sets the name of the business object that the SelectMethod parameter used to specify a sort expression for data source sorting support.

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

public string SortParameterName { get; set; }
/** @property */
public String get_SortParameterName ()

/** @property */
public void set_SortParameterName (String value)

public function get SortParameterName () : String

public function set SortParameterName (value : String)

Property Value

The name of the method parameter used to indicate the parameter which is used to sort the data. The default is an empty string.

The SortParameterName property is used to support data source sorting. When a SortExpression property is set on the DataSourceSelectArguments object and passed to the Select method, the SortParameterName value identifies the parameter name of the SelectMethod business object method according to which the data is sorted.

If the ObjectDataSource is associated with a data-bound control, the values that are passed to this parameter take the form of comma-separated field values followed by "ASC" or "DESC". For example, the value for an ascending sort on Name would be "Name ASC".

The SortParameterName property delegates to the SortParameterName property of the ObjectDataSourceView object that is associated with the ObjectDataSource control.

This section contains two code examples. The first code example demonstrates how to implement a type that supports sorting. The second code example demonstrates how to implement a sort expression.

The following code example demonstrates how to implement a type that supports sorting. The SelectMethod of the SortingData class takes a parameter, sortExpression. The string that is passed to SelectMethod is used for the Sort property of the DataView object that is returned by SelectMethod.

The following code example demonstrates how to implement a sort expression. The code in the Web page creates an instance of the ObjectDataSource control. The TypeName property is set to SortingData and the SortParameterName property is set to sortExpression. The AllowSorting property of the GridView control is set to true. When the user clicks the Sort button, the field name, Name or Number, is passed to the select method in the sort parameter.

<%@ Register TagPrefix="aspSample" Namespace="Samples.AspNet.CS" Assembly="Samples.AspNet.CS" %>
<%@ Page Language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 

<script runat="server">

</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:GridView ID="GridView1" 
            runat="server" 
            DataSourceID="ObjectDataSource1"
            AllowSorting="True">
        </asp:GridView>
        <asp:ObjectDataSource 
            ID="ObjectDataSource1" 
            runat="server" 
            SelectMethod="SelectMethod" 
            TypeName="Samples.AspNet.CS.SortingData" 
            SortParameterName="sortExpression">
        </asp:ObjectDataSource>
    </div>
    </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:
© 2015 Microsoft