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

DropDownTree in RadGrid

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
  • Smith
    • 23
    • 2
  • zzzssss new name567
    • Tester
  • Schmendrik
  • LeguizamoAA23
    • gr4trt
    • hbgjhgj
  • taglialatela
  • plutr
  • dsadasd
  • ljlwww
  • erter
  • yadav
  • jk
  • xxxxxxxxxxxxxxxx
  • Bob
  • H
    • Tester
  • sdfg
  • wqAA
  • a
  • bbG
  • weqwe
  • eqewqw
  • sdadasdsadasdasdasds
  • Dario
  • FHJKJHF
  • Dario
  • 123
  • dddd444
  • 123
  • Me
  • a
  • Bas
  • dd
  • Smith
  • a
  • Test
  • 85
  • 21e
  • 1
  • yool
  • G
  • b
  • aa
  • test
  • test
  • pj
  • 1
  • 1
  • d
  • 1
  • j
  • ccccc
  • 222
  • DSFGSDFGSDFGFD
  • Bob
  • Test
  • hhh
  • 1
  • sasdasda
  • dasda
  • adasd
  • tt
  • No nbv
  • ádas
  • 23
  • 23
  • 121
  • 1212
  • 111
  • asd
  • asda
  • a
  • ginanjar
  • bbbbb
  • xx
  • edward
  • Name
  • fff
  • r
  • f
 
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") %>'
  • DefaultCS.aspx
  • DefaultCS.aspx.cs
<%@ Page AutoEventWireup="true" CodeFile="DefaultCS.aspx.cs" Inherits="DropDownTree.Examples.ApplicationScenarios.DropDownTreeInGrid.DefaultCS"Language="c#"  %>

<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
<%@ Register TagPrefix="qsf" Namespace="Telerik.QuickStart" %>
<!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