0
votes

I'm using telerik radgrid to make an app. One of the columns is set as a template column:

<telerik:GridTemplateColumn DataField="CustomerID" DataType="System.Int32" FilterControlAltText="Filter CustomerID column" HeaderText="Customer" SortExpression="CustomerID" UniqueName="CustomerID">
                                <InsertItemTemplate>
                                    <asp:DropDownList ID="ddlInsertCustomer" runat="server" DataSourceID="SqlDataCustomers" DataTextField="customerName" DataValueField="id" SelectedValue='<%# Bind("CustomerID") %>'>
                                    </asp:DropDownList>
                                </InsertItemTemplate>
                                <EditItemTemplate>
                                    <asp:DropDownList ID="ddlCustomer" runat="server" DataSourceID="SqlDataCustomers" DataTextField="customerName" DataValueField="id" SelectedValue='<%# Bind("CustomerID") %>'>
                                    </asp:DropDownList>
                                </EditItemTemplate>
                                <ItemTemplate>
                                    <asp:Label ID="CustomerIDLabel" runat="server" Text='<%# Eval("CustomerID") %>'></asp:Label>
                                </ItemTemplate>
                            </telerik:GridTemplateColumn>

In the backend on the databound I set the text of this column to the name of the Customer which I get through a linq query to a seperate table.

The problem is in the filtering when I try to filter the table is expecting the id and not the name. Does anyone know how to filter by the text in the column instead of the value?

1

1 Answers

0
votes

Perhaps your easiest option is to include the needed field in the grid's data source so it can filter by it automatically: http://www.telerik.com/help/aspnet-ajax/grid-implementing-filtering-for-gridtemplatecolumns.html. This article also offers a customized approach that you can look into.

You can also try adding filter expressions on the client if you have the needed data in the dropdown list (e.g., as its Value fields), but I am not sure this works for template columns: http://www.telerik.com/help/aspnet-ajax/grid-client-side-binding-adding-sort-filter-expressions.html.