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

How to add control to FilterTemplate

4 Answers 141 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jadesada
Top achievements
Rank 1
Jadesada asked on 22 Jun 2011, 05:22 AM
I have code like this

<Columns>
                        <telerik:GridBoundColumn DataField="TaskID" HeaderText="taskID"
                           UniqueName="TaskID" Visible="False">
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="TaskName" HeaderText="ชื่องาน"
                           UniqueName="TaskName">
                            <FilterTemplate>
                                <telerik:RadComboBox ID="RadComboBox1" Runat="server"
                                    ShowToggleImage="False" Skin="Vista" AutoPostBack="True"
                                    MarkFirstMatch="True" EnableLoadOnDemand="true"
                                    onitemsrequested="RadComboBox1_ItemsRequested"
                                    onselectedindexchanged="RadComboBox1_SelectedIndexChanged">
                                </telerik:RadComboBox>
                            </FilterTemplate>
                        </telerik:GridBoundColumn>
                        <telerik:GridEditCommandColumn>
                        </telerik:GridEditCommandColumn>
                        <telerik:GridButtonColumn CommandName="Delete"
                            ConfirmText="Do you want to delete this item?" ConfirmTitle="Delete"
                            Text="Delete" UniqueName="column1">
                        </telerik:GridButtonColumn>
                    </Columns>


In this code I add "RadComboBox1" to FilterTemplate on GridBoundColumn name "ชื่องาน" on Design page on aspx

but I don't want to add this control like this. I want to add this control using Code Behind help me please.

4 Answers, 1 is accepted

Sort by
0
Veli
Telerik team
answered on 24 Jun 2011, 09:15 AM
Hello Jadesada,

You use RadGrid's ItemCreated event for that:

protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
{
    if(e.Item is GridFilteringItem)
    {
        GridFilterItem filterItem =(GridFilteringItem)e.Item;
        TableCell filterCell = filterItem["TaskName"];
        //add controsl programmatically to filterCell.Controls
    }
}

Veli
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

0
Jadesada
Top achievements
Rank 1
answered on 24 Jun 2011, 10:57 AM
I use your solution but it's show error message "Cannot find a cell bound to column name 'TaskName'"

What can I do sir.
0
Veli
Telerik team
answered on 24 Jun 2011, 11:34 AM
What is the UniqueName of your column with the FilterTemplate? You need to use that name.

Veli
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

0
Jadesada
Top achievements
Rank 1
answered on 24 Jun 2011, 11:58 AM
Thanks I get it :)
Tags
Grid
Asked by
Jadesada
Top achievements
Rank 1
Answers by
Veli
Telerik team
Jadesada
Top achievements
Rank 1
Share this question
or