DataControlField.SortExpression Propiedad

Definición

Obtiene o establece una expresión de ordenación utilizada por un control de origen de datos para ordenar los datos.

public:
 virtual property System::String ^ SortExpression { System::String ^ get(); void set(System::String ^ value); };
[System.ComponentModel.TypeConverter("System.Web.UI.Design.DataSourceViewSchemaConverter, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
public virtual string SortExpression { get; set; }
[System.ComponentModel.TypeConverter("System.Web.UI.Design.DataSourceViewSchemaConverter, System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
public virtual string SortExpression { get; set; }
[<System.ComponentModel.TypeConverter("System.Web.UI.Design.DataSourceViewSchemaConverter, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")>]
member this.SortExpression : string with get, set
[<System.ComponentModel.TypeConverter("System.Web.UI.Design.DataSourceViewSchemaConverter, System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")>]
member this.SortExpression : string with get, set
Public Overridable Property SortExpression As String

Valor de propiedad

String

Una expresión de ordenación utilizada por un control de origen de datos para ordenar los datos. El valor predeterminado es una cadena vacía ("").

Atributos

Ejemplos

En el ejemplo de código siguiente se muestra cómo usar la SortExpression propiedad para asignar una expresión de ordenación a un campo de control de datos.

<%@ page language="C#" %>
<!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 runat="server">
    <title>ASP.NET Example</title>
</head>
<body>
  <form id="form1" runat="server">

    <asp:sqldatasource
      id="SqlDataSource1"
      runat="server"
      connectionstring="<%$ ConnectionStrings:MyNorthwind%>"
      selectcommand="Select * From Employees">
    </asp:sqldatasource>

    <asp:detailsview
      id="DetailsView1"
      runat="server"
      allowpaging="True"
      datasourceid="SqlDataSource1"
      height="208px"
      width="264px"
      autogeneraterows="False">
        <fields>

          <asp:boundfield
            sortexpression="LastName"
            datafield="LastName"
            headertext="LastName">
              <itemstyle backcolor="Yellow">
              </itemstyle>
          </asp:boundfield>

          <asp:boundfield
            sortexpression="FirstName"
            datafield="FirstName"
            headertext="FirstName">
              <itemstyle forecolor="#C00000">
              </itemstyle>
          </asp:boundfield>

          <asp:buttonfield
            text="TestButton"
            buttontype="Button">
          </asp:buttonfield>

        </fields>
    </asp:detailsview>

  </form>
</body>
</html>
<%@ page language="VB" %>
<!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 runat="server">
    <title>ASP.NET Example</title>
</head>
<body>
  <form id="form1" runat="server">

    <asp:sqldatasource
      id="SqlDataSource1"
      runat="server"
      connectionstring="<%$ ConnectionStrings:MyNorthwind%>"
      selectcommand="Select * From Employees">
    </asp:sqldatasource>

    <asp:detailsview
      id="DetailsView1"
      runat="server"
      allowpaging="True"
      datasourceid="SqlDataSource1"
      height="208px"
      width="264px"
      autogeneraterows="False">
        <fields>

          <asp:boundfield
            sortexpression="LastName"
            datafield="LastName"
            headertext="LastName">
              <itemstyle backcolor="Yellow">
              </itemstyle>
          </asp:boundfield>

          <asp:boundfield
            sortexpression="FirstName"
            datafield="FirstName"
            headertext="FirstName">
              <itemstyle forecolor="#C00000">
              </itemstyle>
          </asp:boundfield>

          <asp:buttonfield
            text="TestButton"
            buttontype="Button">
          </asp:buttonfield>

        </fields>
    </asp:detailsview>

  </form>
</body>
</html>

Comentarios

Se OnFieldChanged llama al método para generar un evento de cambio de estado cuando se establece la SortExpression propiedad .

El valor de la SortExpression propiedad se almacena en estado de vista.

Se aplica a