New to Telerik UI for ASP.NET AJAX? Download free 30-day trial

DropDownTree in Grid

Edit the grid entries to be able to adjust the supplier name with the help of the RadDropDownTree. The control shows the suppliers' hierarchy.
Supplier NameTerritoryTerritoryID Edit
No records to display.
There are two options to pre-select a value in the RadDropDownTree when it is nested in the RadGrid EditTemplate.
If you populate RadDropDownTree with data using ASP.NET 2.0 or 3.5 DataSource types, you can simply set the SelectedValue or SelectedText in the following way:
  • SelectedValue='<%#Bind("EmployeeID") %>'
  • SelectedText='<%#Bind("LastName") %>'
  • DefaultVB.aspx
  • DefaultVB.aspx.vb
<%@ Page AutoEventWireup="true" CodeFile="DefaultVB.aspx.vb" Inherits="DropDownTree.Examples.ApplicationScenarios.DropDownTreeInGrid.DefaultVB"Language="vb"  %>

<%@ Register TagPrefix="qsf" Namespace="Telerik.QuickStart" %>
<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>

<!DOCTYPE html>
<html xmlns='http://www.w3.org/1999/xhtml'>
<head runat="server">
    <title>Telerik ASP.NET Example</title>
</head>
<body>
    <form id="form1" runat="server">
    <telerik:RadScriptManager runat="server" ID="RadScriptManager1" />
    <telerik:RadSkinManager ID="RadSkinManager1" runat="server" ShowChooser="true" />
    <telerik:RadAjaxManager runat="server" ID="RadAjaxManager1">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="RadGrid2">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadGrid2" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>
    <qsf:MessageBox ID="InformationBox1" runat="server" Type="Info" Icon="Info">
        Edit the grid entries to be able to adjust the supplier name with the help of the RadDropDownTree. 
            The control shows the suppliers' hierarchy.
    </qsf:MessageBox>
    <div class="demo-container">
        <telerik:RadGrid RenderMode="Lightweight" ID="RadGrid2" GridLines="None" AutoGenerateColumns="false" PageSize="20"
            AllowPaging="true" AllowSorting="true" runat="server" OnItemDataBound="RadGrid2_ItemDataBound"
            DataSourceID="SqlDataSource1" AllowAutomaticUpdates="true"
            ShowStatusBar="true" OnItemCreated="RadGrid2_ItemCreated">
            <MasterTableView ShowFooter="false" TableLayout="Fixed" EditMode="InPlace" CommandItemDisplay="TopAndBottom" CommandItemSettings-ShowAddNewRecordButton="false">
                <SortExpressions>
                    <telerik:GridSortExpression FieldName="TerritoryID" SortOrder="Ascending" />
                </SortExpressions>
                <Columns>
                    <telerik:GridTemplateColumn HeaderText="Supplier Name">
                        <ItemTemplate>
                            <%#DataBinder.Eval(Container.DataItem, "LastName")%>
                        </ItemTemplate>
                        <EditItemTemplate>
                            <telerik:RadDropDownTree RenderMode="Lightweight" runat="server" ID="RadDropDownTreeTest" DataTextField="LastName" DataFieldParentID="ReportsTo"
                                DataFieldID="EmployeeID" OnDataBound="RadDropDownTreeTest_DataBound"
                                DataValueField="EmployeeID" DataSourceID="SqlDataSource2" SelectedValue='<%#Bind("EmployeeID") %>'>
                                <DropDownSettings OpenDropDownOnLoad="true" CloseDropDownOnSelection="true" />
                            </telerik:RadDropDownTree>
                        </EditItemTemplate>
                    </telerik:GridTemplateColumn>
                    <telerik:GridBoundColumn DataField="TerritoryDescription" HeaderText="Territory" />
                    <telerik:GridBoundColumn DataField="TerritoryID" HeaderText="TerritoryID" />
                    <telerik:GridEditCommandColumn FooterText="EditCommand footer" UniqueName="EditCommandColumn"
                        HeaderText="Edit" HeaderStyle-Width="100px" UpdateText="Update">
                    </telerik:GridEditCommandColumn>
                </Columns>
            </MasterTableView>
        </telerik:RadGrid>
    </div>
    <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString35 %>"
        SelectCommand="SELECT EmployeeID, ReportsTo, LastName FROM [Employees]"></asp:SqlDataSource>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString35 %>"
        SelectCommand="SELECT mediator.[EmployeeID], mediator.[TerritoryID], territories.[TerritoryDescription], empl.[LastName]
                            FROM [EmployeeTerritories] AS mediator
                            INNER JOIN Employees AS empl
                            ON mediator.EmployeeID = empl.EmployeeID
                            INNER JOIN Territories AS territories
                            ON mediator.TerritoryID = territories.TerritoryID"
        UpdateCommand="UPDATE EmployeeTerritories
                       SET  EmployeeTerritories.EmployeeID = @EmployeeID
                       WHERE EmployeeTerritories.TerritoryID = @TerritoryID">
        <UpdateParameters>
            <asp:Parameter Name="EmployeeID" Type="Int32" />
            <asp:Parameter Name="TerritoryID" Type="Int32" />
        </UpdateParameters>
    </asp:SqlDataSource>
    </form>
</body>
</html>

Support & Learning Resources

Find Assistance