Hierarchical Grid bound to WCF Service

1 reply. Last post: December 15, 2009 11:44 PM by Glenn Layaar
Tags :
  • New Discussion
  • New Question
  • New Product Feedback

Hi

I have bound WebGrid to DataSet. I get DataSet from a WCF Service.

Please have a look on attached picture.

In Listbox you can see all rows.

But the WebGrid shows only the roottable and the first childtable! Why?

I can reproduce this behavoir only if i get DataSet from a WCF Service! It works, if i copy the method ProductHierarchy_Sel() to local page.

What could be the problem?

        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("...." + nr["Name"].ToString());
                    foreach (DataRow var in nr.GetChildRows("relContactNrContactVariant"))
                    {
                        ListBox1.Items.Add("........" + var["Name"].ToString());
                        foreach (DataRow c in var.GetChildRows("relContactVariantCoil"))
                        {
                            ListBox1.Items.Add("..........." + 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();
            }
        }

The method ProductHierarchy_Sel()

        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;
            }
        }

 

1 attachment
All times are GMT -5. The time now is 10:22 PM.
Previous Next