Skip to main content
A newer version of this page is available. .

How to: Item Template

  • 2 minutes to read

This example illustrates how the layout of editor list items can be modified by creating a template for the dropdown grid’s data rows via the GridViewProperties.Templates.DataRow property (GridViewTemplates.DataRow).

Note that the incremental filtering functionality (enabled via the ASPxGridLookup.IncrementalFilteringMode property) works correctly when list item templating is used.

In this demo, incremental filtering is performed over the values of the first two data columns defined within the editor’s ASPxGridLookup.Columns collection - ‘First Name’ and ‘Last Name’. These columns are pointed by the ASPxGridLookup.TextFormatString property using indexed placeholders ({0} and {1}) that correspond to column indexes within the ASPxGridLookup.Columns collection. Thus, the ASPxGridLookup.TextFormatString property defines the format for displaying the selected item’s value within the edit box (‘First Name’ ‘Last Name’) and serves as a column pointer and format designator for the incremental filtering functionality.

gridlookup-templates.png

    protected void Page_Load(object sender, EventArgs e) {
        GridLookup.GridView.Width = 300;
        GridLookup.GridView.DataBound += grdSelectFilters_SelectFilters_DataBound;
        UpdateGridViewHeigth();
    }
    protected void grdSelectFilters_SelectFilters_DataBound(object sender, EventArgs e) {
        UpdateGridViewHeigth();
    }
    protected void UpdateGridViewHeigth() {
        if (GridLookup.GridView.VisibleRowCount > 2) {
            GridLookup.GridView.Settings.ShowVerticalScrollBar = true;
            GridLookup.GridView.Settings.VerticalScrollableHeight = 300;
        }
        else 
            GridLookup.GridView.Settings.ShowVerticalScrollBar = false;
    }