RadComboBox for custom RadFilterDataFieldEditor changing to Textbox

2 posts, 0 answers
  1. Lee
    Lee avatar
    1 posts
    Member since:
    Oct 2012

    Posted 09 Oct 2012 Link to this post

    I have a RadFilter with a custom FieldEditor control inside the <FieldEditors></FieldEditors> tags.

    The custom field control is a class inherited from RadFilterDataFieldEditor.

    In the InitializeEditor(System.Web.UI.Control container) method, a RadComboBox is instantiated and
    added to the Controls collection of the container parameter.   The DataTextField property of the RadComboBox is text while the DataValueField property of the RadComboBox is a numeric value corresponding to the text's numeric ID.

    When a filter expression is added, the dropdown listbox is displayed for selecting the filter value as the text.  However once the RadFilter Apply button is clicked on postback, the combobox changes to a textbox with the numeric value.

    Can't figure out why this is happening.  Could use some help!  Thanks in advance.


  2. Tsvetina
    Tsvetina avatar
    2481 posts

    Posted 12 Oct 2012 Link to this post

    Hello Lee,

    This sounds like a problem related to instantiating the field editor correctly. Can you confirm that you follow closely the event sequence from our sample of custom field editors:
    Filter / Custom Field Editors

    Make sure that you either declare the editor in mark-up, or declare it on initial Page_Load:
    protected void Page_Load(object sender, EventArgs e)
        if (!IsPostBack)
            RadFilterDropDownEditor dropDownFieldEditor = new RadFilterDropDownEditor();
            dropDownFieldEditor.FieldName = "Country";
            dropDownFieldEditor.DataTextField = "Country";
            dropDownFieldEditor.DataValueField = "Country";
            dropDownFieldEditor.DataSource = GetEmployeesDataTable().DefaultView.ToTable(true, "Country");

    Then, on FieldEditorCreating you should always instantiate the editor:
    protected void RadFilter1_FieldEditorCreating(object sender, RadFilterFieldEditorCreatingEventArgs e)
        if (e.EditorType == "RadFilterDropDownEditor")
            e.Editor = new RadFilterDropDownEditor();

    Additionally, when following these instructions, make sure that you have ViewState enabled for the filter.

    All the best,
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Back to Top