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

how to crate Hierarical Tree using webservice some code are attached that i am using Please Help!

3 Answers 58 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
noman nadeem
Top achievements
Rank 1
noman nadeem asked on 20 Aug 2009, 01:50 PM
hi!
i used webservices to bind data in  telerik tree i have three tables i want to connect each other i dont understand
how to do this i got a example in the forum i did some work on it
  please  used it and tell me how to assign the datasource to bind the hierarchical tree i am sending some code here
Regards,
noman

i am using SectionsDataSource please read and help or send me any example like that want to create hierarchical tree using
this webservice that are given below:



its my example.xaml

<UserControl x:Class="SLCareerM3.Example"
       xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
       xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
       xmlns:telerik="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls"
       xmlns:telerikNavigation="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Navigation"
       xmlns:local="clr-namespace:SLCareerM3" Width="400" Height="300">
    <UserControl.Resources>
        <local:SectionsDataSource  x:Key="MyList" />
        <DataTemplate x:Key="section82">
            <TextBlock Text="{Binding Name}" />
        </DataTemplate>
        <telerik:HierarchicalDataTemplate x:Key="section81" ItemTemplate="{StaticResource section82}"
               ItemsSource="{Binding section82s}">
            <TextBlock Text="{Binding Name}" />
        </telerik:HierarchicalDataTemplate>
        <telerik:HierarchicalDataTemplate x:Key="section8" ItemTemplate="{StaticResource section81}"
               ItemsSource="{Binding section81s}">
            <TextBlock Text="{Binding Name}" />
        </telerik:HierarchicalDataTemplate>
    </UserControl.Resources>
    <Grid>
        <telerikNavigation:RadTreeView Height="300" Width="300"
               ItemsSource="{Binding Source={StaticResource MyList}}"
               ItemTemplate="{StaticResource section8}" />
    </Grid>
</UserControl>



its my Example.cs


namespace SLCareerM3
{
    public partial class Example : UserControl
    {
        public Example()
        {
            InitializeComponent();
            //Loaded += new RoutedEventHandler(UserControl_Loaded);
           
        }

    }



    public class section8
    {
        //public string headingid { get; set; }
        public string headingname { get; set; }
        public section8(string name)
        {
            _name = name;
            _section81 = new List<section81>();
        }

        string _name;
        public string Name { get { return _name; } }
        List<section81> _section81;
        public List<section81> section81s { get { return _section81; } }

    }

    public class section81
    {
        //public string sub_heading_id1 { get; set; }
        public string heading_id1 { get; set; }
        public string sub_heading_name1 { get; set; }

        public section81(string name)
        {
            _name = name;
            _section82 = new List<section82>();
        }
        string _name;
        public string Name { get { return _name; } }
        List<section82> _section82;
        public List<section82> section82s { get { return _section82; } }


    }

    public class section82
    {
        //public string detail_id2 { get; set; }
        public string sub_heading_id2 { get; set; }
        public string Heading_id2 { get; set; }
        public string detail_text2 { get; set; }
        public section82(string name)
        {
            _name = name;
        }
        string _name;
        public string Name { get { return _name; } }


    }
    public class SectionsDataSource : List<section8>
    {
        List<Asection8> sectionList = new List<Asection8>();
        List<Asection81> sectionList1 = new List<Asection81>();
        List<Asection82> sectionList2 = new List<Asection82>();

        public class Asection8
        {
            public string headingid { get; set; }
            public string headingname { get; set; }

        }

        public class Asection81
        {
            public string sub_heading_id1 { get; set; }
            public string heading_id1 { get; set; }
            public string sub_heading_name1 { get; set; }



        }

        public class Asection82
        {
            public string detail_id2 { get; set; }
            public string sub_heading_id2 { get; set; }
            public string Heading_id2 { get; set; }
            public string detail_text2 { get; set; }


        }


        void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
            BasicHttpBinding bind = new BasicHttpBinding();

            bind.MaxReceivedMessageSize = 2147483647;
            bind.MaxBufferSize = 2147483647;

            //EndpointAddress endpoint = new EndpointAddress("http://localhost:51103/serviceTest_Web/myService.asmx");theSercice.myServiceSoapClient textureSoapClient = new serviceTest.theSercice.myServiceSoapClient(bind, endpoint);
            //textureSoapClient.RetrieveTextureAsync();

            //EndpointAddress endpoint = new EndpointAddress("http://localhost:51103/serviceTest_Web/myService.asmx"); theSercice.myServiceSoapClient textureSoapClient = new serviceTest.theSercice.myServiceSoapClient(bind, endpoint);

            //textureSoapClient.RetrieveTextureAsync();
            //textureSoapClient.RetrieveTextureCompleted +=  new EventHandler(textureSoapClient_RetrieveTextureCompleted);





            EndpointAddress endpoint = new EndpointAddress("http://localhost:1258/CareerM/Profile.asmx");
            //http://www.emmaculate.com/CareerM/
            //EndpointAddress endpoint = new EndpointAddress("http://www.emmaculate.com/CareerM/Profile.asmx");

            ServiceProfile3.ProfileSoapClient textureSoapClient = new ServiceProfile3.ProfileSoapClient(bind, endpoint);


            textureSoapClient.RetrieveTreeAsync();
            //.RetrieveTextureAsync();
            textureSoapClient.RetrieveTreeCompleted +=
            new EventHandler<ServiceProfile3.RetrieveTreeCompletedEventArgs>(textureSoapClient_RetrieveTreeCompleted);



            //textureSoapClient.RetrieveTextureCompleted +=
            //new EventHandler<serviceTest.theSercice.RetrieveTextureCompletedEventArgs>(textureSoapClient_RetrieveTextureCompleted);

        }

        void textureSoapClient_RetrieveTreeCompleted(object sender, ServiceProfile3.RetrieveTreeCompletedEventArgs e)
        {
            if (e.Error == null)

                displayData(e.Result);

        }
        void displayData(string xmlContent)
        {

            try
            {
                if (xmlContent != string.Empty)
                {
                    XDocument xmlSections = XDocument.Parse(xmlContent);

                   // #region 0
                    var sections = from section8 in xmlSections.Descendants("section8")

                                   select new

                                   {
                                       headingid = (string)section8.Element("headingid").Value.PadLeft(10, '0'),
                                       headingname = (string)section8.Element("headingname").Value.PadLeft(10, '0')


                                   };





                    var sections1 = from section81 in xmlSections.Descendants("section81")

                                    select new

                                    {
                                        sub_heading_id1 = (string)section81.Element("sub_heading_id1").Value.PadLeft(10, '0'),
                                        heading_id1 = (string)section81.Element("headingid1").Value.PadLeft(10, '0'),
                                        subheadingname1 = (string)section81.Element("sub_heading_name1").Value.PadLeft(10, '0'),


                                        //txPath = (string)"http://www.texturearchive.com/thumbs/" + texture.Element("class1").Value + "/" + texture.Element("class2").Value + "/" + texture.Element("item").Value.PadLeft(10, '0') + "_" + texture.Element("Artist").Value.PadLeft(10, '0') + "_tn.jpg",

                                        // detailtext1 = (string)section81.Element("detailtext1").Value.PadLeft(10, '0')







                                    };



                    var sections2 = from section82 in xmlSections.Descendants("section82")

                                    select new

                                    {
                                        detailid2 = (string)section82.Element("detail_id2").Value.PadLeft(10, '0'),
                                        sub_heading_id2 = (string)section82.Element("sub_heading_id2").Value.PadLeft(10, '0'),
                                        heading_id2 = (string)section82.Element("heading_id2").Value.PadLeft(10, '0'),
                                        //subheadingname2 = (string)section82.Element("subheadingname2").Value.PadLeft(10, '0'),

                                        detailtext2 = (string)section82.Element("detail_text2").Value.PadLeft(10, '0')







                                    };




                    //Bug: http://silverlight.net/forums/t/11147.aspx
                    //List<Asection8> sectionList = new List<Asection8>();
                    foreach (var t in sections)
                    {
                        Asection8 pdt = new Asection8 { headingid = t.headingid, headingname = t.headingname };


                        sectionList.Add(pdt);

                    }

                    //List<Asection81> sectionList1 = new List<Asection81>();
                    foreach (var t in sections1)
                    {
                        Asection81 pdt1 = new Asection81 { heading_id1 = t.heading_id1, sub_heading_id1 = t.sub_heading_id1, sub_heading_name1 = t.subheadingname1 };


                        sectionList1.Add(pdt1);

                    }

                    // List<Asection82> sectionList2 = new List<Asection82>();
                    foreach (var t in sections2)
                    {
                        Asection82 pdt2 = new Asection82 { Heading_id2 = t.heading_id2, sub_heading_id2 = t.sub_heading_id2, detail_id2 = t.detailid2, detail_text2 = t.detailtext2 };


                        sectionList2.Add(pdt2);

                    }

                    //string text="";
                    //for (int a=0;a<= int.Parse(sectionList.Count.ToString()) ; a++)
                    //{
                    //    for (int b=0;b<= int.Parse(sectionList1.Count.ToString()) ; b++)
                    //    {

                    //      for (int c=0;c<= int.Parse(sectionList2.Count.ToString()) ; c++)
                    //      {
                    //            section8 l;
                    //            section81 d;
                    //            Add(l = new section8(sectionList1[0].ToString() ));
                    //            l.section81s.Add((d = new section81(sectionList2[0].ToString())));
                    //           d.section82s.Add(new section82(sectionList[0].ToString()));
                    //      }

                    //    }

                    //}



                    //#endregion



                    // texturesDataGrid.ItemsSource = texturesList;
                    //CustomersGrid.ItemsSource = profilesList;

                    //RadTreeViewItem item = new RadTreeViewItem();
                    //                    item.ItemsSource = sectionList;
                    //item.DataContext = sectionList;
                    //RadTreeView rd = new RadTreeView();
                    //rd.DataContext = sectionList;



                }

                else
                {

                    //errMessage.Visibility = Visibility.Visible;
                    //texturesDataGrid.ItemsSource = null;
                    //CustomersGrid.ItemsSource = null;
                }

            }
            catch (Exception ex)
            {
                Console.Write(ex.Message);

            }

        }






        public SectionsDataSource()
        {

           
            //        RoutedEventHandler Loaded;
            //        Loaded +=new RoutedEventHandler(UserControl_Loaded);

            ////         RoutedEventHandler += new RoutedEventHandler(UserControl_Loaded);
           // UserControl_Loaded();
 
  //how to load first webservice to load the data ?

            string text = "";
            for (int a = 0; a <= int.Parse(sectionList.Count.ToString()); a++)
            {
                for (int b = 0; b <= int.Parse(sectionList1.Count.ToString()); b++)
                {

                    for (int c = 0; c <= int.Parse(sectionList2.Count.ToString()); c++)
                    {
                        section8 l;
                        section81 d;
                        Add(l = new section8(sectionList1[0].ToString()));
                        l.section81s.Add((d = new section81(sectionList2[0].ToString())));
                        d.section82s.Add(new section82(sectionList[0].ToString()));
                    }

                }

            }



            //section8 l;
            //section81 d;
            //Add(l = new section8("1"));
            //l.section81s.Add((d = new section81("1")));
            //d.section82s.Add(new section82("1"));
            //d.section82s.Add(new section82("2"));
            //d.section82s.Add(new section82("3"));
            //d.section82s.Add(new section82("4"));
            //d.section82s.Add(new section82("5"));
            //l.section81s.Add((d = new section81("2")));
            //d.section82s.Add(new section82("1"));
            //d.section82s.Add(new section82("2"));
            //d.section82s.Add(new section82("3"));
            //d.section82s.Add(new section82("4"));
            //d.section82s.Add(new section82("5"));
            //l.section81s.Add((d = new section81("3")));
            //d.section82s.Add(new section82("1"));
            //d.section82s.Add(new section82("2"));
            //d.section82s.Add(new section82("3"));
            //d.section82s.Add(new section82("4"));
            //Add(l = new section8("2"));
            //l.section81s.Add((d = new section81("1")));
            //d.section82s.Add(new section82("1"));
            //d.section82s.Add(new section82("2"));
            //d.section82s.Add(new section82("3"));
            //l.section81s.Add((d = new section81("2")));
            //d.section82s.Add(new section82("1"));
            //d.section82s.Add(new section82("2"));
            //d.section82s.Add(new section82("3"));
            //d.section82s.Add(new section82("4"));
            //l.section81s.Add((d = new section81("3")));
            //d.section82s.Add(new section82("1"));
            //d.section82s.Add(new section82("2"));
            //d.section82s.Add(new section82("3"));

        }


    }





    public class League
    {
        public League(string name)
        {
            _name = name;
            _divisions = new List<Division>();
        }

        string _name;
        public string Name { get { return _name; } }
        List<Division> _divisions;
        public List<Division> Divisions { get { return _divisions; } }
    }
    public class Division
    {
        public Division(string name)
        {
            _name = name;
            _teams = new List<Team>();
        }
        string _name;
        public string Name { get { return _name; } }
        List<Team> _teams;
        public List<Team> Teams { get { return _teams; } }
    }
    public class Team
    {
        public Team(string name)
        {
            _name = name;
        }
        string _name;
        public string Name { get { return _name; } }
    }
    public class LeaguesDataSource : List<League>
    {
        public LeaguesDataSource()
        {
            League l;
            Division d;
            Add(l = new League("League A"));
            l.Divisions.Add((d = new Division("Division A")));
            d.Teams.Add(new Team("Team I"));
            d.Teams.Add(new Team("Team II"));
            d.Teams.Add(new Team("Team III"));
            d.Teams.Add(new Team("Team IV"));
            d.Teams.Add(new Team("Team V"));
            l.Divisions.Add((d = new Division("Division B")));
            d.Teams.Add(new Team("Team Blue"));
            d.Teams.Add(new Team("Team Red"));
            d.Teams.Add(new Team("Team Yellow"));
            d.Teams.Add(new Team("Team Green"));
            d.Teams.Add(new Team("Team Orange"));
            l.Divisions.Add((d = new Division("Division C")));
            d.Teams.Add(new Team("Team East"));
            d.Teams.Add(new Team("Team West"));
            d.Teams.Add(new Team("Team North"));
            d.Teams.Add(new Team("Team South"));
            Add(l = new League("League B"));
            l.Divisions.Add((d = new Division("Division A")));
            d.Teams.Add(new Team("Team 1"));
            d.Teams.Add(new Team("Team 2"));
            d.Teams.Add(new Team("Team 3"));
            d.Teams.Add(new Team("Team 4"));
            d.Teams.Add(new Team("Team 5"));
            l.Divisions.Add((d = new Division("Division B")));
            d.Teams.Add(new Team("Team Diamond"));
            d.Teams.Add(new Team("Team Heart"));
            d.Teams.Add(new Team("Team Club"));
            d.Teams.Add(new Team("Team Spade"));
            l.Divisions.Add((d = new Division("Division C")));
            d.Teams.Add(new Team("Team Alpha"));
            d.Teams.Add(new Team("Team Beta"));
            d.Teams.Add(new Team("Team Gamma"));
            d.Teams.Add(new Team("Team Delta"));
            d.Teams.Add(new Team("Team Epsilon"));
        }
    }

}


mywebservice

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Data;
using MySql.Data;
using MySql;
using MySql.Data.MySqlClient;
using System.Text;

using System.ServiceModel.Configuration;
using System.ServiceModel.Activation;
using System.Security.Principal;
using System.Web.Configuration;
 
using System.Configuration;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

/// <summary>
/// Summary description for Profile
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
// [System.Web.Script.Services.ScriptService]
public class Profile : System.Web.Services.WebService
{
   
    public Profile()
    {

        //Uncomment the following line if using designed components
        //InitializeComponent();
    }

    [WebMethod]
    public string HelloWorld()
    {
        return "Hello World";
    }





    [WebMethod(EnableSession = true)]
    public string RetrieveTree()
    {

        try
        {
            MySqlConnection _mysqlConnection = new MySqlConnection();
            _mysqlConnection.ConnectionString = ConfigurationManager.ConnectionStrings["CMMysql"].ToString();
            _mysqlConnection.Open();
            // //8education
            string userid = "";
            string profileid = "";
            if (HttpContext.Current.Session["Userid"].ToString() == "" || HttpContext.Current.Session["Userid"].ToString() == null)
                userid = "1";
            else
                userid = HttpContext.Current.Session["Userid"].ToString();


            if (HttpContext.Current.Session["Profileid"].ToString() == "" || HttpContext.Current.Session["Profileid"].ToString() == null)
                profileid = "4";
            else
                profileid = HttpContext.Current.Session["Profileid"].ToString();

            //8//education
            MySqlDataAdapter da = new MySqlDataAdapter();
            //da.SelectCommand = new MySqlCommand("SELECT t.itemId,t.Artist,t.class1,t.class2,t.Path,c.colorid,c.itemid,c.colorname,c.price FROM Texture t,texturecolor c where t.itemId=c.itemid LIMIT 0, 20", _mysqlConnection);
            //da.SelectCommand = new MySqlCommand("select thd.detail_id,thd.sub_heading_id,thd.heading_id,thd.detail_text,thd.detail_html , th.heading_id,th.heading_name ,th.user_id,tsh.sub_heading_id,tsh.sub_heading_name , tsh.heading_id  from tbl_heading_details thd , tbl_heading th , tbl_sub_heading tsh where thd.heading_id = th.heading_id and thd.sub_heading_id = tsh.sub_heading_id and th.section_id=8 and th.user_id = " + userid + " and profile_id= " + profileid, _mysqlConnection);
            da.SelectCommand = new MySqlCommand("select * from tbl_heading where section_id=8 and user_id = " + userid + " and th.profile_id= " + profileid, _mysqlConnection);
            DataSet ds = new DataSet();
            da.Fill(ds);


            //8//education
            MySqlDataAdapter da1 = new MySqlDataAdapter();
            //da.SelectCommand = new MySqlCommand("SELECT t.itemId,t.Artist,t.class1,t.class2,t.Path,c.colorid,c.itemid,c.colorname,c.price FROM Texture t,texturecolor c where t.itemId=c.itemid LIMIT 0, 20", _mysqlConnection);
            //da.SelectCommand = new MySqlCommand("select thd.detail_id,thd.sub_heading_id,thd.heading_id,thd.detail_text,thd.detail_html , th.heading_id,th.heading_name ,th.user_id,tsh.sub_heading_id,tsh.sub_heading_name , tsh.heading_id  from tbl_heading_details thd , tbl_heading th , tbl_sub_heading tsh where thd.heading_id = th.heading_id and thd.sub_heading_id = tsh.sub_heading_id and th.section_id=8 and th.user_id = " + userid + " and profile_id= " + profileid, _mysqlConnection);
            da1.SelectCommand = new MySqlCommand("select * from tbl_sub_heading", _mysqlConnection);
            DataSet ds1 = new DataSet();
            da1.Fill(ds1);



            //8//education
            MySqlDataAdapter da2 = new MySqlDataAdapter();
            //da.SelectCommand = new MySqlCommand("SELECT t.itemId,t.Artist,t.class1,t.class2,t.Path,c.colorid,c.itemid,c.colorname,c.price FROM Texture t,texturecolor c where t.itemId=c.itemid LIMIT 0, 20", _mysqlConnection);
            //da.SelectCommand = new MySqlCommand("select thd.detail_id,thd.sub_heading_id,thd.heading_id,thd.detail_text,thd.detail_html , th.heading_id,th.heading_name ,th.user_id,tsh.sub_heading_id,tsh.sub_heading_name , tsh.heading_id  from tbl_heading_details thd , tbl_heading th , tbl_sub_heading tsh where thd.heading_id = th.heading_id and thd.sub_heading_id = tsh.sub_heading_id and th.section_id=8 and th.user_id = " + userid + " and profile_id= " + profileid, _mysqlConnection);
            da2.SelectCommand = new MySqlCommand("select * from tbl_heading_details", _mysqlConnection);
            DataSet ds2 = new DataSet();
            da2.Fill(ds2);



            ////1//7experience
            //MySqlDataAdapter da1 = new MySqlDataAdapter();
            ////da.SelectCommand = new MySqlCommand("SELECT t.itemId,t.Artist,t.class1,t.class2,t.Path,c.colorid,c.itemid,c.colorname,c.price FROM Texture t,texturecolor c where t.itemId=c.itemid LIMIT 0, 20", _mysqlConnection);
            //da1.SelectCommand = new MySqlCommand("select thd.detail_id,thd.sub_heading_id,thd.heading_id,thd.detail_text,thd.detail_html , th.heading_id,th.heading_name ,th.user_id,tsh.sub_heading_id,tsh.sub_heading_name , tsh.heading_id  from tbl_heading_details thd , tbl_heading th , tbl_sub_heading tsh where thd.heading_id = th.heading_id and thd.sub_heading_id = tsh.sub_heading_id and th.section_id=7 and th.user_id = " + userid + " and profile_id= " + profileid, _mysqlConnection);
            //DataSet ds1 = new DataSet();
            //da1.Fill(ds1);

            ////2//4Achievement
            ////3//9recomendation
            ////4//10links
            ////5 //3careerhighlights


            ////2//4Achievement
            //MySqlDataAdapter da2 = new MySqlDataAdapter();
            ////da.SelectCommand = new MySqlCommand("SELECT t.itemId,t.Artist,t.class1,t.class2,t.Path,c.colorid,c.itemid,c.colorname,c.price FROM Texture t,texturecolor c where t.itemId=c.itemid LIMIT 0, 20", _mysqlConnection);
            //da2.SelectCommand = new MySqlCommand("select thd.detail_id,thd.sub_heading_id,thd.heading_id,thd.detail_text,thd.detail_html , th.heading_id,th.heading_name ,th.user_id,tsh.sub_heading_id,tsh.sub_heading_name , tsh.heading_id  from tbl_heading_details thd , tbl_heading th , tbl_sub_heading tsh where thd.heading_id = th.heading_id and thd.sub_heading_id = tsh.sub_heading_id and th.section_id=4 and th.user_id = " + userid + " and profile_id= " + profileid, _mysqlConnection);
            //DataSet ds2 = new DataSet();
            //da2.Fill(ds2);



            ////3//9recomendation
            //MySqlDataAdapter da3 = new MySqlDataAdapter();
            ////da.SelectCommand = new MySqlCommand("SELECT t.itemId,t.Artist,t.class1,t.class2,t.Path,c.colorid,c.itemid,c.colorname,c.price FROM Texture t,texturecolor c where t.itemId=c.itemid LIMIT 0, 20", _mysqlConnection);
            //da3.SelectCommand = new MySqlCommand("select thd.detail_id,thd.sub_heading_id,thd.heading_id,thd.detail_text,thd.detail_html , th.heading_id,th.heading_name ,th.user_id,tsh.sub_heading_id,tsh.sub_heading_name , tsh.heading_id  from tbl_heading_details thd , tbl_heading th , tbl_sub_heading tsh where thd.heading_id = th.heading_id and thd.sub_heading_id = tsh.sub_heading_id and th.section_id=9 and th.user_id = " + userid + " and profile_id= " + profileid, _mysqlConnection);
            //DataSet ds3 = new DataSet();
            //da3.Fill(ds3);


            ////4//10links
            //MySqlDataAdapter da4 = new MySqlDataAdapter();
            ////da.SelectCommand = new MySqlCommand("SELECT t.itemId,t.Artist,t.class1,t.class2,t.Path,c.colorid,c.itemid,c.colorname,c.price FROM Texture t,texturecolor c where t.itemId=c.itemid LIMIT 0, 20", _mysqlConnection);
            //da4.SelectCommand = new MySqlCommand("select thd.detail_id,thd.sub_heading_id,thd.heading_id,thd.detail_text,thd.detail_html , th.heading_id,th.heading_name ,th.user_id,tsh.sub_heading_id,tsh.sub_heading_name , tsh.heading_id  from tbl_heading_details thd , tbl_heading th , tbl_sub_heading tsh where thd.heading_id = th.heading_id and thd.sub_heading_id = tsh.sub_heading_id and th.section_id=10 and th.user_id = " + userid + " and profile_id= " + profileid, _mysqlConnection);
            //DataSet ds4 = new DataSet();
            //da4.Fill(ds4);


            ////5 //3careerhighlights
            //MySqlDataAdapter da5 = new MySqlDataAdapter();
            ////da.SelectCommand = new MySqlCommand("SELECT t.itemId,t.Artist,t.class1,t.class2,t.Path,c.colorid,c.itemid,c.colorname,c.price FROM Texture t,texturecolor c where t.itemId=c.itemid LIMIT 0, 20", _mysqlConnection);
            //da5.SelectCommand = new MySqlCommand("select thd.detail_id,thd.sub_heading_id,thd.heading_id,thd.detail_text,thd.detail_html , th.heading_id,th.heading_name ,th.user_id,tsh.sub_heading_id,tsh.sub_heading_name , tsh.heading_id  from tbl_heading_details thd , tbl_heading th , tbl_sub_heading tsh where thd.heading_id = th.heading_id and thd.sub_heading_id = tsh.sub_heading_id and th.section_id=3 and th.user_id = " + userid + " and profile_id= " + profileid, _mysqlConnection);
            //DataSet ds5 = new DataSet();
            //da5.Fill(ds5);






            StringBuilder sb = new StringBuilder();
            sb.Append("<?xml version=\"1.0\" encoding=\"utf-8\" ?>");

            sb.Append("<sections>");
            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                sb.Append("<section8>");

                sb.Append("<headingid>");

                sb.Append(dr[0].ToString());

                sb.Append("</headingid>");


                sb.Append("<headingname>");

                sb.Append(dr[1].ToString());

                sb.Append("</headingname>");

              

                sb.Append("</section8>");

            }


            foreach (DataRow dr1 in ds1.Tables[0].Rows)
            {
                sb.Append("<section81>");



                sb.Append("<sub_heading_id1>");

                sb.Append(dr1[0].ToString());

                sb.Append("</sub_heading_id1>");


                sb.Append("<headingid1>");

                sb.Append(dr1[1].ToString());

                sb.Append("</headingid1>");


                sb.Append("<sub_heading_name1>");

                sb.Append(dr1[2].ToString());

                sb.Append("</sub_heading_name1>");

           

                sb.Append("</section81>");

            }



            foreach (DataRow dr2 in ds2.Tables[0].Rows)
            {
                sb.Append("<section82>");



                sb.Append("<detail_id2>");

                sb.Append(dr2[0].ToString());

                sb.Append("</detail_id2>");


                sb.Append("<sub_heading_id2>");

                sb.Append(dr2[1].ToString());

                sb.Append("</sub_heading_id2>");


                sb.Append("<Heading_id2>");

                sb.Append(dr2[2].ToString());

                sb.Append("</Heading_id2>");


                sb.Append("<detail_text2>");

                sb.Append(dr2[4].ToString());

                sb.Append("</detail_text2>");


                sb.Append("</section82>");

            }

               



         



            sb.Append("</sections>");

            _mysqlConnection.Close();
            return sb.ToString();

        }
        catch (Exception ex)
        {
            return string.Empty;

        }



    }
}




3 Answers, 1 is accepted

Sort by
0
Tihomir Petkov
Telerik team
answered on 20 Aug 2009, 03:43 PM
Hi noman,

You can take a look at our KB articles and online examples:

http://www.telerik.com/support/kb/silverlight/treeview/radtreeview-and-hierarchicaldatatemplate.aspx
http://www.telerik.com/support/kb/silverlight/treeview/how-to-bind-radtreeview-to-hierarchical-data-and-use-load-on-demand.aspx

http://demos.telerik.com/silverlight/#TreeView/HierarchicalTemplate
http://demos.telerik.com/silverlight/#TreeView/DataBinding

If you have any specific questions regarding the data binding process, I will be glad to answer.

All the best,
Tihomir Petkov
the Telerik team


Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
noman nadeem
Top achievements
Rank 1
answered on 21 Aug 2009, 05:41 AM
Hello Tihomir Petkov!
I am stuck on making data source all the things are done fixed source hierarchical  tree have been made but from database using webservices i got the data but i am not getting syntax to make the datasource that is given below,
i am getting the data in my example.cs from services and using property how to create Datasource using List.


can you please tell me how to bind fixed datasource to database i want to make it dynamic through web serivce
example
like this datasource its fixed i want to get data from database how i dont know the syntax

public class DataSource : List<Organization> 
    public DataSource() 
    { 
        Organization telerik = new Organization("Telerik"); 
        Department silverlight = new Department("Silverlight"); 
        Department wpf = new Department("WPF"); 
 
        telerik.Departments.Add(silverlight); 
        telerik.Departments.Add(wpf); 
 
        silverlight.Employees.Add(new Person("John")); 
        silverlight.Employees.Add(new Person("Ben")); 
        silverlight.Employees.Add(new Person("Ann")); 
 
        wpf.Employees.Add(new Person("Karoline")); 
        wpf.Employees.Add(new Person("Simone")); 
        wpf.Employees.Add(new Person("Eduard")); 
 
        this.Add(telerik); 
    } 
}



and another example that i give you earlier

public class LeaguesDataSource : List<League>
    {
        public LeaguesDataSource()
        {
            League l;
            Division d;
            Add(l = new League("League A"));
            l.Divisions.Add((d = new Division("Division A")));
            d.Teams.Add(new Team("Team I"));
            d.Teams.Add(new Team("Team II"));
            d.Teams.Add(new Team("Team III"));
            d.Teams.Add(new Team("Team IV"));
            d.Teams.Add(new Team("Team V"));
            l.Divisions.Add((d = new Division("Division B")));
            d.Teams.Add(new Team("Team Blue"));
            d.Teams.Add(new Team("Team Red"));
            d.Teams.Add(new Team("Team Yellow"));
            d.Teams.Add(new Team("Team Green"));
            d.Teams.Add(new Team("Team Orange"));
            l.Divisions.Add((d = new Division("Division C")));
            d.Teams.Add(new Team("Team East"));
            d.Teams.Add(new Team("Team West"));
            d.Teams.Add(new Team("Team North"));
            d.Teams.Add(new Team("Team South"));
            Add(l = new League("League B"));
            l.Divisions.Add((d = new Division("Division A")));
            d.Teams.Add(new Team("Team 1"));
            d.Teams.Add(new Team("Team 2"));
            d.Teams.Add(new Team("Team 3"));
            d.Teams.Add(new Team("Team 4"));
            d.Teams.Add(new Team("Team 5"));
            l.Divisions.Add((d = new Division("Division B")));
            d.Teams.Add(new Team("Team Diamond"));
            d.Teams.Add(new Team("Team Heart"));
            d.Teams.Add(new Team("Team Club"));
            d.Teams.Add(new Team("Team Spade"));
            l.Divisions.Add((d = new Division("Division C")));
            d.Teams.Add(new Team("Team Alpha"));
            d.Teams.Add(new Team("Team Beta"));
            d.Teams.Add(new Team("Team Gamma"));
            d.Teams.Add(new Team("Team Delta"));
            d.Teams.Add(new Team("Team Epsilon"));
        }
    }


i change it from database using webservice like this but not correctly i am making some mistakes please help on it i am attaching the code

this is my web serivce method are given below i have three table heading , sub heading and detail table i want to get data from all of this and make datasource as are given above.

[WebMethod(EnableSession = true)]
    public string RetrieveTree()
    {

        try
        {
            MySqlConnection _mysqlConnection = new MySqlConnection();
            _mysqlConnection.ConnectionString = ConfigurationManager.ConnectionStrings["CMMysql"].ToString();
            _mysqlConnection.Open();
            // //8education
            string userid = "";
            string profileid = "";
            if (HttpContext.Current.Session["Userid"].ToString() == "" || HttpContext.Current.Session["Userid"].ToString() == null)
                userid = "1";
            else
                userid = HttpContext.Current.Session["Userid"].ToString();


            if (HttpContext.Current.Session["Profileid"].ToString() == "" || HttpContext.Current.Session["Profileid"].ToString() == null)
                profileid = "4";
            else
                profileid = HttpContext.Current.Session["Profileid"].ToString();

            //8//education
            MySqlDataAdapter da = new MySqlDataAdapter();
            //da.SelectCommand = new MySqlCommand("SELECT t.itemId,t.Artist,t.class1,t.class2,t.Path,c.colorid,c.itemid,c.colorname,c.price FROM Texture t,texturecolor c where t.itemId=c.itemid LIMIT 0, 20", _mysqlConnection);
            //da.SelectCommand = new MySqlCommand("select thd.detail_id,thd.sub_heading_id,thd.heading_id,thd.detail_text,thd.detail_html , th.heading_id,th.heading_name ,th.user_id,tsh.sub_heading_id,tsh.sub_heading_name , tsh.heading_id  from tbl_heading_details thd , tbl_heading th , tbl_sub_heading tsh where thd.heading_id = th.heading_id and thd.sub_heading_id = tsh.sub_heading_id and th.section_id=8 and th.user_id = " + userid + " and profile_id= " + profileid, _mysqlConnection);
            da.SelectCommand = new MySqlCommand("select * from tbl_heading where section_id=8 and user_id = " + userid + " and th.profile_id= " + profileid, _mysqlConnection);
            DataSet ds = new DataSet();
            da.Fill(ds);


            //8//education
            MySqlDataAdapter da1 = new MySqlDataAdapter();
            //da.SelectCommand = new MySqlCommand("SELECT t.itemId,t.Artist,t.class1,t.class2,t.Path,c.colorid,c.itemid,c.colorname,c.price FROM Texture t,texturecolor c where t.itemId=c.itemid LIMIT 0, 20", _mysqlConnection);
            //da.SelectCommand = new MySqlCommand("select thd.detail_id,thd.sub_heading_id,thd.heading_id,thd.detail_text,thd.detail_html , th.heading_id,th.heading_name ,th.user_id,tsh.sub_heading_id,tsh.sub_heading_name , tsh.heading_id  from tbl_heading_details thd , tbl_heading th , tbl_sub_heading tsh where thd.heading_id = th.heading_id and thd.sub_heading_id = tsh.sub_heading_id and th.section_id=8 and th.user_id = " + userid + " and profile_id= " + profileid, _mysqlConnection);
            da1.SelectCommand = new MySqlCommand("select * from tbl_sub_heading", _mysqlConnection);
            DataSet ds1 = new DataSet();
            da1.Fill(ds1);



            //8//education
            MySqlDataAdapter da2 = new MySqlDataAdapter();
            //da.SelectCommand = new MySqlCommand("SELECT t.itemId,t.Artist,t.class1,t.class2,t.Path,c.colorid,c.itemid,c.colorname,c.price FROM Texture t,texturecolor c where t.itemId=c.itemid LIMIT 0, 20", _mysqlConnection);
            //da.SelectCommand = new MySqlCommand("select thd.detail_id,thd.sub_heading_id,thd.heading_id,thd.detail_text,thd.detail_html , th.heading_id,th.heading_name ,th.user_id,tsh.sub_heading_id,tsh.sub_heading_name , tsh.heading_id  from tbl_heading_details thd , tbl_heading th , tbl_sub_heading tsh where thd.heading_id = th.heading_id and thd.sub_heading_id = tsh.sub_heading_id and th.section_id=8 and th.user_id = " + userid + " and profile_id= " + profileid, _mysqlConnection);
            da2.SelectCommand = new MySqlCommand("select * from tbl_heading_details", _mysqlConnection);
            DataSet ds2 = new DataSet();
            da2.Fill(ds2);



            ////1//7experience
            //MySqlDataAdapter da1 = new MySqlDataAdapter();
            ////da.SelectCommand = new MySqlCommand("SELECT t.itemId,t.Artist,t.class1,t.class2,t.Path,c.colorid,c.itemid,c.colorname,c.price FROM Texture t,texturecolor c where t.itemId=c.itemid LIMIT 0, 20", _mysqlConnection);
            //da1.SelectCommand = new MySqlCommand("select thd.detail_id,thd.sub_heading_id,thd.heading_id,thd.detail_text,thd.detail_html , th.heading_id,th.heading_name ,th.user_id,tsh.sub_heading_id,tsh.sub_heading_name , tsh.heading_id  from tbl_heading_details thd , tbl_heading th , tbl_sub_heading tsh where thd.heading_id = th.heading_id and thd.sub_heading_id = tsh.sub_heading_id and th.section_id=7 and th.user_id = " + userid + " and profile_id= " + profileid, _mysqlConnection);
            //DataSet ds1 = new DataSet();
            //da1.Fill(ds1);

            ////2//4Achievement
            ////3//9recomendation
            ////4//10links
            ////5 //3careerhighlights


            ////2//4Achievement
            //MySqlDataAdapter da2 = new MySqlDataAdapter();
            ////da.SelectCommand = new MySqlCommand("SELECT t.itemId,t.Artist,t.class1,t.class2,t.Path,c.colorid,c.itemid,c.colorname,c.price FROM Texture t,texturecolor c where t.itemId=c.itemid LIMIT 0, 20", _mysqlConnection);
            //da2.SelectCommand = new MySqlCommand("select thd.detail_id,thd.sub_heading_id,thd.heading_id,thd.detail_text,thd.detail_html , th.heading_id,th.heading_name ,th.user_id,tsh.sub_heading_id,tsh.sub_heading_name , tsh.heading_id  from tbl_heading_details thd , tbl_heading th , tbl_sub_heading tsh where thd.heading_id = th.heading_id and thd.sub_heading_id = tsh.sub_heading_id and th.section_id=4 and th.user_id = " + userid + " and profile_id= " + profileid, _mysqlConnection);
            //DataSet ds2 = new DataSet();
            //da2.Fill(ds2);



            ////3//9recomendation
            //MySqlDataAdapter da3 = new MySqlDataAdapter();
            ////da.SelectCommand = new MySqlCommand("SELECT t.itemId,t.Artist,t.class1,t.class2,t.Path,c.colorid,c.itemid,c.colorname,c.price FROM Texture t,texturecolor c where t.itemId=c.itemid LIMIT 0, 20", _mysqlConnection);
            //da3.SelectCommand = new MySqlCommand("select thd.detail_id,thd.sub_heading_id,thd.heading_id,thd.detail_text,thd.detail_html , th.heading_id,th.heading_name ,th.user_id,tsh.sub_heading_id,tsh.sub_heading_name , tsh.heading_id  from tbl_heading_details thd , tbl_heading th , tbl_sub_heading tsh where thd.heading_id = th.heading_id and thd.sub_heading_id = tsh.sub_heading_id and th.section_id=9 and th.user_id = " + userid + " and profile_id= " + profileid, _mysqlConnection);
            //DataSet ds3 = new DataSet();
            //da3.Fill(ds3);


            ////4//10links
            //MySqlDataAdapter da4 = new MySqlDataAdapter();
            ////da.SelectCommand = new MySqlCommand("SELECT t.itemId,t.Artist,t.class1,t.class2,t.Path,c.colorid,c.itemid,c.colorname,c.price FROM Texture t,texturecolor c where t.itemId=c.itemid LIMIT 0, 20", _mysqlConnection);
            //da4.SelectCommand = new MySqlCommand("select thd.detail_id,thd.sub_heading_id,thd.heading_id,thd.detail_text,thd.detail_html , th.heading_id,th.heading_name ,th.user_id,tsh.sub_heading_id,tsh.sub_heading_name , tsh.heading_id  from tbl_heading_details thd , tbl_heading th , tbl_sub_heading tsh where thd.heading_id = th.heading_id and thd.sub_heading_id = tsh.sub_heading_id and th.section_id=10 and th.user_id = " + userid + " and profile_id= " + profileid, _mysqlConnection);
            //DataSet ds4 = new DataSet();
            //da4.Fill(ds4);


            ////5 //3careerhighlights
            //MySqlDataAdapter da5 = new MySqlDataAdapter();
            ////da.SelectCommand = new MySqlCommand("SELECT t.itemId,t.Artist,t.class1,t.class2,t.Path,c.colorid,c.itemid,c.colorname,c.price FROM Texture t,texturecolor c where t.itemId=c.itemid LIMIT 0, 20", _mysqlConnection);
            //da5.SelectCommand = new MySqlCommand("select thd.detail_id,thd.sub_heading_id,thd.heading_id,thd.detail_text,thd.detail_html , th.heading_id,th.heading_name ,th.user_id,tsh.sub_heading_id,tsh.sub_heading_name , tsh.heading_id  from tbl_heading_details thd , tbl_heading th , tbl_sub_heading tsh where thd.heading_id = th.heading_id and thd.sub_heading_id = tsh.sub_heading_id and th.section_id=3 and th.user_id = " + userid + " and profile_id= " + profileid, _mysqlConnection);
            //DataSet ds5 = new DataSet();
            //da5.Fill(ds5);






            StringBuilder sb = new StringBuilder();
            sb.Append("<?xml version=\"1.0\" encoding=\"utf-8\" ?>");

            sb.Append("<sections>");
            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                sb.Append("<section8>");

                sb.Append("<headingid>");

                sb.Append(dr[0].ToString());

                sb.Append("</headingid>");


                sb.Append("<headingname>");

                sb.Append(dr[1].ToString());

                sb.Append("</headingname>");

              

                sb.Append("</section8>");

            }


            foreach (DataRow dr1 in ds1.Tables[0].Rows)
            {
                sb.Append("<section81>");



                sb.Append("<sub_heading_id1>");

                sb.Append(dr1[0].ToString());

                sb.Append("</sub_heading_id1>");


                sb.Append("<headingid1>");

                sb.Append(dr1[1].ToString());

                sb.Append("</headingid1>");


                sb.Append("<sub_heading_name1>");

                sb.Append(dr1[2].ToString());

                sb.Append("</sub_heading_name1>");

           

                sb.Append("</section81>");

            }



            foreach (DataRow dr2 in ds2.Tables[0].Rows)
            {
                sb.Append("<section82>");



                sb.Append("<detail_id2>");

                sb.Append(dr2[0].ToString());

                sb.Append("</detail_id2>");


                sb.Append("<sub_heading_id2>");

                sb.Append(dr2[1].ToString());

                sb.Append("</sub_heading_id2>");


                sb.Append("<Heading_id2>");

                sb.Append(dr2[2].ToString());

                sb.Append("</Heading_id2>");


                sb.Append("<detail_text2>");

                sb.Append(dr2[4].ToString());

                sb.Append("</detail_text2>");


                sb.Append("</section82>");

            }

               



         



            sb.Append("</sections>");

            _mysqlConnection.Close();
            return sb.ToString();

        }
        catch (Exception ex)
        {
            return string.Empty;

        }



    }
}



now in my example.cs i am doing this for making my datasource but not get success yet!
i  am making
SectionsDataSource from web service.


its my Example.cs


namespace SLCareerM3
{
    public partial class Example : UserControl
    {
        public Example()
        {
            InitializeComponent();
            //Loaded += new RoutedEventHandler(UserControl_Loaded);
           
        }

    }



    public class section8
    {
        //public string headingid { get; set; }
        public string headingname { get; set; }
        public section8(string name)
        {
            _name = name;
            _section81 = new List<section81>();
        }

        string _name;
        public string Name { get { return _name; } }
        List<section81> _section81;
        public List<section81> section81s { get { return _section81; } }

    }

    public class section81
    {
        //public string sub_heading_id1 { get; set; }
        public string heading_id1 { get; set; }
        public string sub_heading_name1 { get; set; }

        public section81(string name)
        {
            _name = name;
            _section82 = new List<section82>();
        }
        string _name;
        public string Name { get { return _name; } }
        List<section82> _section82;
        public List<section82> section82s { get { return _section82; } }


    }

    public class section82
    {
        //public string detail_id2 { get; set; }
        public string sub_heading_id2 { get; set; }
        public string Heading_id2 { get; set; }
        public string detail_text2 { get; set; }
        public section82(string name)
        {
            _name = name;
        }
        string _name;
        public string Name { get { return _name; } }


    }
    public class SectionsDataSource : List<section8>
    {
        List<Asection8> sectionList = new List<Asection8>();
        List<Asection81> sectionList1 = new List<Asection81>();
        List<Asection82> sectionList2 = new List<Asection82>();

        public class Asection8
        {
            public string headingid { get; set; }
            public string headingname { get; set; }

        }

        public class Asection81
        {
            public string sub_heading_id1 { get; set; }
            public string heading_id1 { get; set; }
            public string sub_heading_name1 { get; set; }



        }

        public class Asection82
        {
            public string detail_id2 { get; set; }
            public string sub_heading_id2 { get; set; }
            public string Heading_id2 { get; set; }
            public string detail_text2 { get; set; }


        }


        void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
            BasicHttpBinding bind = new BasicHttpBinding();

            bind.MaxReceivedMessageSize = 2147483647;
            bind.MaxBufferSize = 2147483647;

            //EndpointAddress endpoint = new EndpointAddress("http://localhost:51103/serviceTest_Web/myService.asmx");theSercice.myServiceSoapClient textureSoapClient = new serviceTest.theSercice.myServiceSoapClient(bind, endpoint);
            //textureSoapClient.RetrieveTextureAsync();

            //EndpointAddress endpoint = new EndpointAddress("http://localhost:51103/serviceTest_Web/myService.asmx"); theSercice.myServiceSoapClient textureSoapClient = new serviceTest.theSercice.myServiceSoapClient(bind, endpoint);

            //textureSoapClient.RetrieveTextureAsync();
            //textureSoapClient.RetrieveTextureCompleted +=  new EventHandler(textureSoapClient_RetrieveTextureCompleted);





            EndpointAddress endpoint = new EndpointAddress("http://localhost:1258/CareerM/Profile.asmx");
            //http://www.emmaculate.com/CareerM/
            //EndpointAddress endpoint = new EndpointAddress("http://www.emmaculate.com/CareerM/Profile.asmx");

            ServiceProfile3.ProfileSoapClient textureSoapClient = new ServiceProfile3.ProfileSoapClient(bind, endpoint);


            textureSoapClient.RetrieveTreeAsync();
            //.RetrieveTextureAsync();
            textureSoapClient.RetrieveTreeCompleted +=
            new EventHandler<ServiceProfile3.RetrieveTreeCompletedEventArgs>(textureSoapClient_RetrieveTreeCompleted);



            //textureSoapClient.RetrieveTextureCompleted +=
            //new EventHandler<serviceTest.theSercice.RetrieveTextureCompletedEventArgs>(textureSoapClient_RetrieveTextureCompleted);

        }

        void textureSoapClient_RetrieveTreeCompleted(object sender, ServiceProfile3.RetrieveTreeCompletedEventArgs e)
        {
            if (e.Error == null)

                displayData(e.Result);

        }
        void displayData(string xmlContent)
        {

            try
            {
                if (xmlContent != string.Empty)
                {
                    XDocument xmlSections = XDocument.Parse(xmlContent);

                   // #region 0
                    var sections = from section8 in xmlSections.Descendants("section8")

                                   select new

                                   {
                                       headingid = (string)section8.Element("headingid").Value.PadLeft(10, '0'),
                                       headingname = (string)section8.Element("headingname").Value.PadLeft(10, '0')


                                   };





                    var sections1 = from section81 in xmlSections.Descendants("section81")

                                    select new

                                    {
                                        sub_heading_id1 = (string)section81.Element("sub_heading_id1").Value.PadLeft(10, '0'),
                                        heading_id1 = (string)section81.Element("headingid1").Value.PadLeft(10, '0'),
                                        subheadingname1 = (string)section81.Element("sub_heading_name1").Value.PadLeft(10, '0'),


                                        //txPath = (string)"http://www.texturearchive.com/thumbs/" + texture.Element("class1").Value + "/" + texture.Element("class2").Value + "/" + texture.Element("item").Value.PadLeft(10, '0') + "_" + texture.Element("Artist").Value.PadLeft(10, '0') + "_tn.jpg",

                                        // detailtext1 = (string)section81.Element("detailtext1").Value.PadLeft(10, '0')







                                    };



                    var sections2 = from section82 in xmlSections.Descendants("section82")

                                    select new

                                    {
                                        detailid2 = (string)section82.Element("detail_id2").Value.PadLeft(10, '0'),
                                        sub_heading_id2 = (string)section82.Element("sub_heading_id2").Value.PadLeft(10, '0'),
                                        heading_id2 = (string)section82.Element("heading_id2").Value.PadLeft(10, '0'),
                                        //subheadingname2 = (string)section82.Element("subheadingname2").Value.PadLeft(10, '0'),

                                        detailtext2 = (string)section82.Element("detail_text2").Value.PadLeft(10, '0')







                                    };




                    //Bug: http://silverlight.net/forums/t/11147.aspx
                    //List<Asection8> sectionList = new List<Asection8>();
                    foreach (var t in sections)
                    {
                        Asection8 pdt = new Asection8 { headingid = t.headingid, headingname = t.headingname };


                        sectionList.Add(pdt);

                    }

                    //List<Asection81> sectionList1 = new List<Asection81>();
                    foreach (var t in sections1)
                    {
                        Asection81 pdt1 = new Asection81 { heading_id1 = t.heading_id1, sub_heading_id1 = t.sub_heading_id1, sub_heading_name1 = t.subheadingname1 };


                        sectionList1.Add(pdt1);

                    }

                    // List<Asection82> sectionList2 = new List<Asection82>();
                    foreach (var t in sections2)
                    {
                        Asection82 pdt2 = new Asection82 { Heading_id2 = t.heading_id2, sub_heading_id2 = t.sub_heading_id2, detail_id2 = t.detailid2, detail_text2 = t.detailtext2 };


                        sectionList2.Add(pdt2);

                    }

                    //string text="";
                    //for (int a=0;a<= int.Parse(sectionList.Count.ToString()) ; a++)
                    //{
                    //    for (int b=0;b<= int.Parse(sectionList1.Count.ToString()) ; b++)
                    //    {

                    //      for (int c=0;c<= int.Parse(sectionList2.Count.ToString()) ; c++)
                    //      {
                    //            section8 l;
                    //            section81 d;
                    //            Add(l = new section8(sectionList1[0].ToString() ));
                    //            l.section81s.Add((d = new section81(sectionList2[0].ToString())));
                    //           d.section82s.Add(new section82(sectionList[0].ToString()));
                    //      }

                    //    }

                    //}



                    //#endregion



                    // texturesDataGrid.ItemsSource = texturesList;
                    //CustomersGrid.ItemsSource = profilesList;

                    //RadTreeViewItem item = new RadTreeViewItem();
                    //                    item.ItemsSource = sectionList;
                    //item.DataContext = sectionList;
                    //RadTreeView rd = new RadTreeView();
                    //rd.DataContext = sectionList;



                }

                else
                {

                    //errMessage.Visibility = Visibility.Visible;
                    //texturesDataGrid.ItemsSource = null;
                    //CustomersGrid.ItemsSource = null;
                }

            }
            catch (Exception ex)
            {
                Console.Write(ex.Message);

            }

        }






        public SectionsDataSource()
        {

           
            //        RoutedEventHandler Loaded;
            //        Loaded +=new RoutedEventHandler(UserControl_Loaded);

            ////         RoutedEventHandler += new RoutedEventHandler(UserControl_Loaded);
           // UserControl_Loaded();
 
  //how to load first webservice to load the data ?

            string text = "";
            for (int a = 0; a <= int.Parse(sectionList.Count.ToString()); a++)
            {
                for (int b = 0; b <= int.Parse(sectionList1.Count.ToString()); b++)
                {

                    for (int c = 0; c <= int.Parse(sectionList2.Count.ToString()); c++)
                    {
                        section8 l;
                        section81 d;
                        Add(l = new section8(sectionList1[0].ToString()));
                        l.section81s.Add((d = new section81(sectionList2[0].ToString())));
                        d.section82s.Add(new section82(sectionList[0].ToString()));
                    }

                }

            }



            //section8 l;
            //section81 d;
            //Add(l = new section8("1"));
            //l.section81s.Add((d = new section81("1")));
            //d.section82s.Add(new section82("1"));
            //d.section82s.Add(new section82("2"));
            //d.section82s.Add(new section82("3"));
            //d.section82s.Add(new section82("4"));
            //d.section82s.Add(new section82("5"));
            //l.section81s.Add((d = new section81("2")));
            //d.section82s.Add(new section82("1"));
            //d.section82s.Add(new section82("2"));
            //d.section82s.Add(new section82("3"));
            //d.section82s.Add(new section82("4"));
            //d.section82s.Add(new section82("5"));
            //l.section81s.Add((d = new section81("3")));
            //d.section82s.Add(new section82("1"));
            //d.section82s.Add(new section82("2"));
            //d.section82s.Add(new section82("3"));
            //d.section82s.Add(new section82("4"));
            //Add(l = new section8("2"));
            //l.section81s.Add((d = new section81("1")));
            //d.section82s.Add(new section82("1"));
            //d.section82s.Add(new section82("2"));
            //d.section82s.Add(new section82("3"));
            //l.section81s.Add((d = new section81("2")));
            //d.section82s.Add(new section82("1"));
            //d.section82s.Add(new section82("2"));
            //d.section82s.Add(new section82("3"));
            //d.section82s.Add(new section82("4"));
            //l.section81s.Add((d = new section81("3")));
            //d.section82s.Add(new section82("1"));
            //d.section82s.Add(new section82("2"));
            //d.section82s.Add(new section82("3"));

        }


    }
















0
Tihomir Petkov
Telerik team
answered on 21 Aug 2009, 12:17 PM
Hi noman,

I already answered to your other ticket on the same topic (ticket ID 236588). Please refer to it for my answer.

Greetings,
Tihomir Petkov
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
TreeView
Asked by
noman nadeem
Top achievements
Rank 1
Answers by
Tihomir Petkov
Telerik team
noman nadeem
Top achievements
Rank 1
Share this question
or