<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
<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
| Property | Values | Default | Description |
|---|---|---|---|
| FilterExpression | SQL fragment with {0} | The WHERE-clause fragment XMP appends to the list query when the user submits the search |
Captions and labels
| Property | Default |
|---|---|
| SearchLabelText | Search |
| SearchButtonText | Search |
| SortLabelText | Sort |
| SortButtonText | Sort |
| ReverseSortText | Reverse |
Sort columns
| Property | Values | Description |
|---|---|---|
| SortFieldNames | comma-list | Comma-delimited list of column names that the user can sort by |
| SortFieldLabels | comma-list | Comma-delimited list of friendly captions for the columns. Maps positionally to SortFieldNames |
CSS classes
| Property | Default | Applies to |
|---|---|---|
| SearchLabelCssClass | Normal | The "Search:" label |
| SearchBoxCssClass | NormalTextBox | The search input box |
| SearchButtonCssClass | CommandButton | The Search button |
| SortLabelCssClass | Normal | The "Sort:" label |
| SortFieldListCssClass | NormalTextBox | The sort-column dropdown |
| SortButtonCssClass | CommandButton | The Sort button |
| ReverseSortCssClass | Normal | The Reverse checkbox |
| CssClass | The 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.
| Property | Values | Description |
|---|---|---|
| BackColor | color name | #dddddd | Background color of the panel |
| BorderColor | color name | #dddddd | Border color of the panel |
| BorderStyle | NotSet None Dotted Dashed Solid Double Groove Ridge Inset Outset | Border style |
| BorderWidth | size | Border width |
| Font-Bold | True False | Bold text |
| Font-Italic | True False | Italic text |
| Font-Names | string | Font family name |
| Font-Overline | True False | Overline text decoration |
| Font-Size | size or named size | Font size |
| Font-Strikeout | True False | Strikethrough |
| Font-Underline | True False | Underline |
| ForeColor | color name | #dddddd | Text color |
| Width | size | Panel width |
| Height | size | Panel 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.textFilterExpression="FirstName LIKE '%{0}%'"If the user enters
John, the effective filter becomesFirstName 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:textFilterExpression="FirstName LIKE '%{0}%' OR LastName LIKE '%{0}%'"SortFieldNames / SortFieldLabels: Two comma-delimited lists, mapped positionally.
List Contains SortFieldNamesColumn names exactly as they appear in the data source — used in the resulting ORDER BYSortFieldLabelsFriendly captions shown in the dropdown to the user If
SortFieldLabelshas fewer entries thanSortFieldNames, the missing labels fall back to the column name. IfSortFieldLabelsis 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:
| Token | Replaced 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.