Export (0) Print
Expand All

IFilterProvider.NoFilter Event

NOTE: This API is now obsolete.

Notifies the consumer Web Part that no filter will be provided.

Namespace:  Microsoft.SharePoint.WebPartPages.Communication
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)

[ObsoleteAttribute("Use System.Web.UI.WebControls.WebParts.IWebPartParameters instead")]
event NoFilterEventHandler NoFilter

The following code example shows an overridden PartCommunicationMain method that fires the NoFilter event. This code example is part of a larger example provided for the IFilterProvider interface.

// Step #7: Override the PartCommunicationMain() method.
// The PartCommunicationMain method is called by the Web Part 
// infrastructure on the client during the ASP.NET PreRender
// event to allow the part to pass its primary data to the other 
// connected parts.
// It is important to always fire either the SetFilter, NoFilter, or 
// ClearFilter event. Some parts
// may not behave properly if they are left waiting for this 
// information.
// SetFilter should be fired to send the filter expression.
// NoFilter should be fired to indicate that there is no change in the 
// filter expression.
// ClearFilter should be fired to indicate that the filter should be 
// removed.

public override void PartCommunicationMain()
{
    // Ensure that all of the Web Part's controls are created.
    EnsureChildControls();

    // Check if connected.
    if(_connected)
    {
        // Check which button was clicked.
        if(_setFilterClicked == true)
        {
            // If there is a listener, fire the SetFilter event.
            if (SetFilter != null)
            {
                // Create the SetFilterEventArgs object for the 
                // SetFilter event.
                SetFilterEventArgs setFilterEventArgs = new 
                   SetFilterEventArgs();

                // Create the filter expression.
                int eIndex = 1;
                string filterExpression = string.Empty;
                for (int index = 0; index < _fieldList.Length; index++)
                {
                    // This filter expression syntax should be used 
                    // with SharePoint lists
                    // and other Microsoft Web Parts that support the 
                    // IFilterConsumer interface.
                    if (_filterInputs[index].Text != string.Empty)
                    {
                        filterExpression += FieldLabel + 
                           eIndex.ToString() + "=" + _fieldList[index] 
                           + "&";
                        filterExpression += ValueLabel + 
                           eIndex.ToString() + "=" + 
                           _filterInputs[index].Text + "&";
                        eIndex++;
                    }
                }

                // Trim Off Trailing '&'
                if (filterExpression.Length != 0)
                    filterExpression = filterExpression.Substring(0,filterExpression.Length - 1);
                // Set the FilterExpression property on the 
                // SetFilterEventArgs object.
                setFilterEventArgs.FilterExpression = filterExpression;

                // Set the _filterExpression variable for display in 
                // the user interface.
                _filterExpression = filterExpression;

                // Fire the event.
                SetFilter(this, setFilterEventArgs);

                _setFilterClicked = false;
            }
        }
        else if(_clearFilterClicked == true)
        {
            // If there is a listener, fire the ClearFilter event.
            if (ClearFilter != null)
            {
                ClearFilter(this, new EventArgs());

                _clearFilterClicked = false;

                // Clear out values in input text boxes.
                if (_filterInputs != null)
                {
                    for (int index = 0; index < _filterInputs.Length; 
                       index++)
                        _filterInputs[index].Text = string.Empty;
                }
            }
        }
        else if(_noFilterClicked == true)
        {
            // If there is a listener, fire the NoFilter event.
            if (NoFilter != null)
            {
                NoFilter(this, new EventArgs());

                _noFilterClicked = false;
            }
        }
        else
        {
            // If there is a listner, fire the NoFilter event.
            if (NoFilter != null)
            {
                NoFilter(this, new EventArgs());
            }
        }
    }
}

Show:
© 2014 Microsoft