Set Field Values
Pre-Select an Item in Field Filter Dropdown

Description
This customization shows how to pre-select a list item in the field filter Dropdown list and still preserve the list item "Select All."
Variables
Database Table
Select the database table displayed in the page
Table Control Class
Select the table control where this customization will be included.
Field Filter Dropdown Control
Select a field filter Dropdown list (e.g. CategoryNameFilter)
Field
Select the field corresponding to the filter
Applies to
TableControl class
Code
 
''' 
''' Override CreateWhereClause() to filter the contents of the table
'''   
Public Overrides Function CreateWhereClause() As WhereClause

    ' Call the MyBase.CreateWhereClause()
    Dim wc As WhereClause = MyBase.CreateWhereClause()

    ' If MyBase.CreateWhereClause() returns nothing then create a new 
    ' instance of WhereClause
    If ( IsNothing(wc)) Then
        wc = New WhereClause
    End If           

    ' Table will be filtered only once when the page loads since WhereClause is
    ' added only when it is not a PostBack. If you want to retain the filtering of the table 
    ' add the whereclause outside the if condition which checks for PostBack.
    If (Not Me.Page.IsPostBack) Then
        wc.iAND(${${Database Table}ClassName}.${Field}, BaseFilter.ComparisonOperator.EqualsTo, "some Value",False)
        return wc
    Else
        return wc
    End If     
End Function


''' 
''' Override Populate${Field Filter Dropdown Control} to set the
''' selected item of the filter
'''       
Protected Overrides Sub Populate${Field Filter Dropdown Control}(ByVal selectedValue As String, ByVal maxItems As Integer)                    	      
    
    
    ' The if condition which checks for PostBack will set the ${Field Filter Dropdown Control} 
    ' selected value only when the page loads for the first time.
    ' If you want to retain the selected value of ${Field Filter Dropdown Control} 
    ' remove the If condition which checks for the postback.
    ' Replace "some Value" with the value you want to set for the filter
    If ( Not Me.Page.IsPostBack) Then
        MyBase.Populate${Field Filter Dropdown Control}("some Value", maxItems)
    Else
        MyBase.Populate${Field Filter Dropdown Control}(selectedValue, maxItems)
    End If
	
End Sub


 


  Privacy Statement