This is a migrated thread and some comments may be shown as answers.

Get a custom filter control in the code behind

2 Answers 57 Views
Grid
This is a migrated thread and some comments may be shown as answers.
SCT
Top achievements
Rank 1
SCT asked on 15 May 2012, 09:56 AM

Dear Telerik Team,

 

we would like to get a custom filter control in the code behind. Here is the scenario:

 

ASPX:

                                <telerik:GridBoundColumn DataField="PropertyCaption" HeaderText="Property Caption"

                                    AllowFiltering="true">

                                    <HeaderStyle Width="25%" />

                                    <FilterTemplate>

                                        <telerik:RadComboBox ID="rcbPropertyCaptionFilter" runat="server" DataValueField="PropertyCaption"

                                            DataTextField="PropertyCaption" EmptyMessage="All Types" AllowCustomText="true"

                                            CheckBoxes="true" EnableCheckAllItemsCheckBox="true" Width="240px" />

                                        <telerik:RadButton ID="btnPropertyCaptionFilter" text="Filter" runat="server" OnClick="btnPropertyCaptionFilter_Click"/>

                                    </FilterTemplate>

                                </telerik:GridBoundColumn>

 

CS:

        protected void btnPropertyCaptionFilter_Click(object sender, EventArgs e)

        {

            // Here I need to find control rcbPropertyCaptionFilter

 

            // This access doesn't work

            object example1 = RadGridDataPoints.MasterTableView.FindControl("rcbPropertyCaptionFilter");

            object example2 = RadGridDataPoints.FindControl("rcbPropertyCaptionFilter");

        }

 

Could you tell us please, how to access the rcbPropertyCaptionFilter” control?

Thank you in advance.

SCT

 

2 Answers, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 15 May 2012, 10:11 AM
Hi,

Please take a look into the following code snippet I tried to access the RadComboBox inside the FilterTemplate on a Button Click.

C#:
protected void btnPropertyCaptionFilter_Click(object sender, EventArgs e)
{
    RadButton btn = (RadButton)sender;
    GridFilteringItem item = (GridFilteringItem)btn.NamingContainer;
    RadComboBox combo = (RadComboBox)item.FindControl("rcbPropertyCaptionFilter");
}

Hope this helps.

Thanks,
Shinu.
0
SCT
Top achievements
Rank 1
answered on 15 May 2012, 01:17 PM
Hi Shinu,

thank you very much for your response. We'll try out provided code snippet.

Regards
SCT
Tags
Grid
Asked by
SCT
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
SCT
Top achievements
Rank 1
Share this question
or