Skip to content

<SearchSort>

<SearchSort> adds a search input, a sort dropdown, and a "reverse sort" checkbox to a list view. It's a child of <xmod:Template> or <xmod:DataList> — it doesn't stand on its own.

The FilterExpression attribute is a fragment that XMP appends to the list query's WHERE clause, with {0} substituted for the user's search input. The SortFieldNames and SortFieldLabels properties populate the sort dropdown.

The optional inner content (the display template) lets you arrange the search box, sort dropdown, and labels with your own HTML.

Example

html
<xmod:Template ...>
  ...
  <SearchSort FilterExpression="FirstName LIKE '%{0}%'"
              SearchLabelText="Search For:" SearchButtonText="GO"
              SortFieldNames="FirstName,LastName,Zip"
              SortFieldLabels="First Name,Last Name,Zip Code">
    <table>
      <tr>
        <td><strong>{SearchLabel}</strong> {SearchBox} {SearchButton}</td>
        <td align="right">
          <strong>{SortLabel}</strong> {SortFieldList} {SortButton} Reverse {ReverseSort}
        </td>
      </tr>
    </table>
  </SearchSort>
  ...
</xmod:Template>

Properties

Search filter

PropertyValuesDefaultDescription
FilterExpressionSQL fragment with {0}The WHERE-clause fragment XMP appends to the list query when the user submits the search

Captions and labels

PropertyDefault
SearchLabelTextSearch
SearchButtonTextSearch
SortLabelTextSort
SortButtonTextSort
ReverseSortTextReverse

Sort columns

PropertyValuesDescription
SortFieldNamescomma-listComma-delimited list of column names that the user can sort by
SortFieldLabelscomma-listComma-delimited list of friendly captions for the columns. Maps positionally to SortFieldNames

CSS classes

PropertyDefaultApplies to
SearchLabelCssClassNormalThe "Search:" label
SearchBoxCssClassNormalTextBoxThe search input box
SearchButtonCssClassCommandButtonThe Search button
SortLabelCssClassNormalThe "Sort:" label
SortFieldListCssClassNormalTextBoxThe sort-column dropdown
SortButtonCssClassCommandButtonThe Sort button
ReverseSortCssClassNormalThe Reverse checkbox
CssClassThe whole panel container
Deprecated Properties (styling)

These ASP.NET-style style properties are still recognized but you should prefer CSS — set CssClass on the panel and on each part via the *CssClass properties above.

PropertyValuesDescription
BackColorcolor name | #ddddddBackground color of the panel
BorderColorcolor name | #ddddddBorder color of the panel
BorderStyleNotSet None Dotted Dashed Solid Double Groove Ridge Inset OutsetBorder style
BorderWidthsizeBorder width
Font-BoldTrue FalseBold text
Font-ItalicTrue FalseItalic text
Font-NamesstringFont family name
Font-OverlineTrue FalseOverline text decoration
Font-Sizesize or named sizeFont size
Font-StrikeoutTrue FalseStrikethrough
Font-UnderlineTrue FalseUnderline
ForeColorcolor name | #ddddddText color
WidthsizePanel width
HeightsizePanel height

Property Details

  • FilterExpression: A WHERE-clause fragment (no leading WHERE) with {0} as the placeholder for whatever the user typed in the search box. When the user submits, XMP runs the list query with this fragment AND-ed to its WHERE clause.

    text
    FilterExpression="FirstName LIKE '%{0}%'"

    If the user enters John, the effective filter becomes FirstName LIKE '%John%'. The placeholder is parameterized — user input is sent as a SQL parameter, not concatenated into the SQL — so there's no SQL-injection risk from the user's search text.

    Match multiple columns by combining with OR:

    text
    FilterExpression="FirstName LIKE '%{0}%' OR LastName LIKE '%{0}%'"
  • SortFieldNames / SortFieldLabels: Two comma-delimited lists, mapped positionally.

    ListContains
    SortFieldNamesColumn names exactly as they appear in the data source — used in the resulting ORDER BY
    SortFieldLabelsFriendly captions shown in the dropdown to the user

    If SortFieldLabels has fewer entries than SortFieldNames, the missing labels fall back to the column name. If SortFieldLabels is omitted entirely, every column shows its raw name.

Display Template

Place HTML between <SearchSort> and </SearchSort> to arrange the controls manually. The placeholders below are replaced with the rendered control:

TokenReplaced with
{SearchLabel}The "Search:" label
{SearchBox}The search input
{SearchButton}The Search button
{SortLabel}The "Sort:" label
{SortFieldList}The dropdown of sortable columns
{SortButton}The Sort button
{ReverseSort}The "Reverse" checkbox

If no inner content is supplied, XMP uses its built-in default layout.