﻿<?xml version="1.0" encoding="utf-8"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:media="http://search.yahoo.com/mrss/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0"><channel><title>Intersoft Community - WCF</title><link>http://www.intersoftsolutions.com/Community/Tags/WCF/</link><description /><generator>http://www.intersoftsolutions.com</generator><language>en</language><copyright>Copyright 2002 - 2015 Intersoft Solutions Corp. All rights reserved.</copyright><ttl>60</ttl><item><title>Hierarchical Grid bound to WCF Service</title><link>http://www.intersoftsolutions.com/Community/Tags/WCF/</link><pubDate>Tue, 15 Dec 2009 13:09:20 GMT</pubDate><dc:creator>Michael</dc:creator><category>WCF</category><category>Hierarchical</category><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;I have bound WebGrid to DataSet. I get DataSet from a WCF Service.&lt;/p&gt;
&lt;p&gt;Please have a look on attached picture.&lt;/p&gt;
&lt;p&gt;In Listbox you can see all rows. &lt;/p&gt;
&lt;p&gt;But the WebGrid shows only the roottable and the first childtable! Why?&lt;/p&gt;
&lt;p&gt;I can reproduce this behavoir only if i get DataSet from a WCF Service! It works, if i copy the method &lt;em&gt;ProductHierarchy_Sel()&lt;/em&gt; to local page.&lt;/p&gt;
&lt;p&gt;What could be the problem?&lt;/p&gt;&lt;pre&gt;        DataSet ds2;
        protected void Page_Load(object sender, EventArgs e)
        {
            using (proxyRelays.MasterdataClient proxyMasterdata = new QS_Client.proxyRelays.MasterdataClient())
            {
                ds2 = proxyMasterdata.ProductHierarchy_Sel();
            }
            foreach (DataRow family in ds2.Tables["ProductFamily"].Rows)
            {
                ListBox1.Items.Add(family["Name"].ToString());
                foreach (DataRow nr in family.GetChildRows("relFamilyContactNr"))
                {
                    ListBox1.Items.Add("...." &amp;#43; nr["Name"].ToString());
                    foreach (DataRow var in nr.GetChildRows("relContactNrContactVariant"))
                    {
                        ListBox1.Items.Add("........" &amp;#43; var["Name"].ToString());
                        foreach (DataRow c in var.GetChildRows("relContactVariantCoil"))
                        {
                            ListBox1.Items.Add("..........." &amp;#43; c["Name"].ToString());
                        }
                    }
                }
            }
        }

        protected void grd2_InitializeDataSource(object sender, ISNet.WebUI.WebGrid.DataSourceEventArgs e)
        {
            e.DataSource = ds2;
            grd2.DataMember = "ProductFamily";
            grd2.RootTable.DataMember = "ProductFamily";
        }

        protected void grd2_PrepareDataBinding(object sender, ISNet.WebUI.WebGrid.DataSourceEventArgs e)
        {
            if (!Page.IsPostBack)
            {
                grd2.ClearCachedDataSource();
                grd2.RetrieveHierarchicalStructure();
            }
        }&lt;/pre&gt;

&lt;p&gt;The method &lt;em&gt;ProductHierarchy_Sel()&lt;/em&gt; &lt;/p&gt;&lt;pre&gt;        public DataSet ProductHierarchy_Sel()
        {
            SqlConnection cn = new SqlConnection();
            cn.ConnectionString = ConfigurationManager.ConnectionStrings["QS-SYS"].ConnectionString;
            cn.Open();

            using (cn)
            {
                SqlCommand cmd = new SqlCommand();
                cmd.Connection = cn;
                cmd.CommandText = "EXEC Product.Family_SelWithDep;EXEC Product.ContactNr_SelWithDep;EXEC Product.ContactVariant_SelWithDep;EXEC Product.Coil_SelWithDep";

                SqlDataAdapter da = new SqlDataAdapter();
                da.SelectCommand = cmd;
                da.TableMappings.Add("Table", "ProductFamily");
                da.TableMappings.Add("Table1", "ProductContactNr");
                da.TableMappings.Add("Table2", "ProductContactVariant");
                da.TableMappings.Add("Table3", "ProductCoil");

                DataSet ds = new DataSet();
                da.Fill(ds);
                da.FillSchema(ds, SchemaType.Mapped);

                DataRelation rel;
                rel = new DataRelation("relFamilyContactNr",
                    ds.Tables["ProductFamily"].Columns["ID"],
                    ds.Tables["ProductContactNr"].Columns["FamilyID"]);
                ds.Relations.Add(rel);

                rel = new DataRelation("relContactNrContactVariant",
                    ds.Tables["ProductContactNr"].Columns["ID"],
                    ds.Tables["ProductContactVariant"].Columns["ContactNrID"]);
                ds.Relations.Add(rel);

                rel = new DataRelation("relContactVariantCoil",
                    ds.Tables["ProductContactVariant"].Columns["ID"],
                    ds.Tables["ProductCoil"].Columns["ContactVariantID"]);
                ds.Relations.Add(rel);

                return ds;
            }
        }&lt;/pre&gt;

&lt;p&gt; &lt;/p&gt;</description></item></channel></rss>