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

How to apply Filtering for RadDropdownlist inside edititemtamplate?

1 Answer 39 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Sanath
Top achievements
Rank 1
Sanath asked on 12 Sep 2013, 05:13 PM
Hello,

I have a radgrid with batch edit mode, that has AllowFilteringByColumn enabled. One of the grid column's is populated from a RadDropdownlist using a lookup table (via a foreign key). The filter in this case, only works on the foreign key value.

I am loading Dropdownlist in "PreRender". How can i configure filter for RadDropdownlist ?

ASPX Code:
<%--Product Names--%>
                <telerik:GridTemplateColumn DataField="Product_Names" GroupByExpression="Product_Names Group by Product_Names"
                    UniqueName="Product_Names" InitializeTemplatesFirst="false" HeaderStyle-Width="10%"
                    HeaderText="Product Names" HeaderStyle-Font-Size="12px">
                    <HeaderTemplate>
                        <table>
                            <tr>
                                <td>
                                    <asp:LinkButton ID="lnkSortProduct_Names" runat="server" CommandArgument="Product_Names" CommandName="Sort"
                                        Text="Product Names"></asp:LinkButton>
                                </td>
                                <td>
                                    <img src="Images/Context_new_menu.jpg" style="margin-top: 5px; margin-left: 5px;
                                        cursor: pointer" onclick='ShowColumnHeaderMenu(event,"Product_Names")' alt="Show context menu" />
                                </td>
                            </tr>
                        </table>
                    </HeaderTemplate>
                    
                    <ItemTemplate>
                        <asp:Label ID="lblProduct_Names" runat="server" Text='<%#Eval("Product_Names")%>'></asp:Label>
                    </ItemTemplate>
                    <ItemStyle HorizontalAlign="Left" />
                    
                    <EditItemTemplate>
                        <telerik:RadDropDownList ID="ddlProductNames" runat="server" Width="65px" ToolTip="Choose Product Name" DropDownHeight="150px" DropDownWidth="100px">
                        </telerik:RadDropDownList>
                    </EditItemTemplate>
                </telerik:GridTemplateColumn>

C# Code:

protected void RadGrid1_PreRender(object sender, EventArgs e)
    {
        DataSet ds = new DataSet();
        try
        {
            // Filling Product Names data in Dropdowns
            RadDropDownList ddlProductNames = RadGrid1.FindControl(RadGrid1.MasterTableView.ClientID + "_Product_Names").FindControl("ddlProductNames") as RadDropDownList;

            ds = objFilingAssignments.GetAllddlProductNames();
            if (ds.Tables[0].Rows.Count > 0)
            {
                ddlPreparer.Items.Clear();
                ddlPreparer.DataSource = ds;
                ddlPreparer.DataValueField = "User_Initials";
                ddlPreparer.DataTextField = "User_Initials";
                ddlPreparer.DataBind();
                
            }
            ddlProductNames.DataSource = null;
            ddlProductNames.Dispose();

            
        }
        catch (SqlException ex)
        {
            throw ex;
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }
How can i configure filter for RadDropdownlist ?

Thanks,
Sanath Rohilla.

1 Answer, 1 is accepted

Sort by
0
Konstantin Dikov
Telerik team
answered on 17 Sep 2013, 02:37 PM
Hello Sanath,

I am not sure if I understood your requirement correctly, but if you want to filter the RadDropDownList, please note that there is no built-in filter functionality for the RadDropDownList and you should filter the data before assigning the DataSet to the control.

Also, I could recommend that you have a look at our "Grid - Column types" help article and to see if "GridDropDownColumn" could fit your requirement. 

Additionally, the following articles could also be useful to achieve the required functionality:
 
Hope that helps.

 

Regards,
Konstantin Dikov
Telerik
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 the blog feed now.
Tags
Grid
Asked by
Sanath
Top achievements
Rank 1
Answers by
Konstantin Dikov
Telerik team
Share this question
or