DropdownTree set selected value when load from RadClientBinding

2 posts, 0 answers
  1. Irene Alpen
    Irene Alpen avatar
    19 posts
    Member since:
    Jul 2004

    Posted 11 Jul 2016 Link to this post

    project using RadClientDataSource to binding RadDropdownTree control using WebService WCF. Load data is ok.

    This my code:


    <telerik:RadScriptManager runat="server" ID="RadScriptManager1" />

        <telerik:RadClientDataSource ID="RadClientDataSource1" runat="server" 
            <ClientEvents OnCustomParameter="ParameterMap" OnDataParse="Parse" />
                <WebServiceDataSourceSettings BaseUrl="UserInfoService.svc/">
                    <Select Url="GetDonVis" DataType="JSON" RequestType="Post" ContentType="application/json; charset=utf-8" />
                    <telerik:ClientDataSourceModelField FieldName="MaDonVi" DataType="String" />
                    <telerik:ClientDataSourceModelField FieldName="TenDonVi" DataType="String" />
                    <telerik:ClientDataSourceModelField FieldName="ParentId" DataType="String" />
        <telerik:RadDropDownTree RenderMode="Classic" EnableFiltering="true" ID="RadDropDownTree1" runat="server" 
                DropDownSettings-Height="220px" Width="100%" DropDownSettings-CloseDropDownOnSelection="true"
                ClientDataSourceID="RadClientDataSource1" DataTextField="TenDonVi" 
                DataValueField="MaDonVi" DataFieldID="MaDonVi"
                DataFieldParentID="ParentId" Skin="Office2007">
                    <CollapseAnimation Type="None" />



    [WebInvoke(Method = "POST", ResponseFormat = WebMessageFormat.Json)]
            public CustomersResult GetDonVis()
                //Doc data tu DB
                SqlConnection sqlConnection = new SqlConnection();
                     sqlConnection.ConnectionString = "SERVER=localhost;Database=LongBien;UID=sa;PWD=abcde12345-;";

                     SqlDataAdapter da = new SqlDataAdapter("SELECT * FROM tblDmDonVi;", sqlConnection);
                     DataTable dataTable = new DataTable("DonVi");


                     List<ServiceDonVi> result = new List<ServiceDonVi>();

                     foreach (DataRow dataRow in dataTable.Rows)
                         ServiceDonVi donVi = new ServiceDonVi();
                         donVi.MaDonVi = dataRow["MaDonVi"].ToString();
                         donVi.TenDonVi = dataRow["TenDonVi"].ToString();
                         if (dataRow["ParentId"] != DBNull.Value)
                             donVi.ParentId = dataRow["ParentId"].ToString();



                     CustomersResult a = new CustomersResult();
                     a.Data = result;
                     a.Count = 100;

                     return a;
                 catch (Exception exception)


    But I has problem: 

    1. When addnew data item -> save data in database is ok. (Example: value selected = 5)

    2. When edit this item, how to set selected item keep old value (value = 5) has save in database??? 


  2. Veselin Tsvetanov
    Veselin Tsvetanov avatar
    561 posts

    Posted 14 Jul 2016 Link to this post

    Hi Irene,

    I am not quite sure that I understand correctly your scenario. Could you, please, explain how you add new items to the RadDropDownTree? How do you edit them and what exactly is the problem with values?

    Veselin Tsvetanov
    Telerik by Progress
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
Back to Top