﻿<?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 - WebGrid Enterprise - Webgrid displaying hierarchical data by databinding in code behind</title><link>http://www.intersoftsolutions.com/Community/WebGrid/Webgrid-displaying-hierarchical-data-by-databinding-in-code-behind/</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>Webgrid displaying hierarchical data by databinding in code behind</title><link>http://www.intersoftsolutions.com/Community/WebGrid/Webgrid-displaying-hierarchical-data-by-databinding-in-code-behind/</link><pubDate>Thu, 21 Jan 2010 14:55:53 GMT</pubDate><dc:creator>shawncraig@yahoo.com</dc:creator><description>&lt;p&gt;Hope this helps you out. I cut and pasted it from something I was working on. Let me know if it doesn't work.&lt;/p&gt;&lt;pre&gt;namespace WebApplication4
{
    public partial class _Default : System.Web.UI.Page
    {
        DataSet dsFedApps;

        protected void Page_Load(object sender, EventArgs e)
        {
            DataSet dsAppList = new DataSet();
            dsAppList.Tables.Add(AppTableAdapter.GetData());
            dsAppList.Tables.Add(PropTableAdapter.GetData(0));

            DataRelation rel;
            rel = new DataRelation("relAppProps",
                dsAppList.Tables["AppList"].Columns["FedAppsID"],
                dsAppList.Tables["PropList"].Columns["FedAppsID"]);
            dsAppList.Relations.Add(rel);
        }

        protected void WebGrid1_InitializeDataSource(object sender, ISNet.WebUI.WebGrid.DataSourceEventArgs e)
        {
            e.DataSource = dsFedApps;
            WebGrid1.DataMember = "AppList";
            WebGrid1.RootTable.DataMember = "AppList";
        }

        protected void WebGrid1_PrepareDataBinding(object sender, ISNet.WebUI.WebGrid.DataSourceEventArgs e)
        {
            if (!Page.IsPostBack)
            {
                WebGrid1.ClearCachedDataSource();
                WebGrid1.RetrieveHierarchicalStructure();
            }
        }
    }
}
&lt;/pre&gt;
</description></item><item><title>Webgrid displaying hierarchical data by databinding in code behind</title><link>http://www.intersoftsolutions.com/Community/WebGrid/Webgrid-displaying-hierarchical-data-by-databinding-in-code-behind/</link><pubDate>Thu, 21 Jan 2010 03:45:14 GMT</pubDate><dc:creator>julia</dc:creator><description>&lt;p&gt;Hi Jocelyn,&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;We have some sample for hierarchical mode on server side. You can find it in WebGrid's Tutorials. Kindly go to Intersoft &lt;em&gt;WebUI Studio &amp;gt; WebUI Studio for ASP.NET &amp;gt; WebGrid &amp;gt; C# Tutorial&lt;/em&gt;. There are some sample that may be useful for your need, e.g in &lt;em&gt;folder V3.1 &amp;gt; &lt;strong&gt;LoadOnDemand.aspx&lt;/strong&gt;, &lt;/em&gt;or &lt;em&gt;V4.0 &amp;gt; &lt;strong&gt;BindingHierarchicalObjects_LoadOnDemand.aspx&lt;/strong&gt;.&lt;/em&gt; I hope this sample can help you.&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;One more thing, the best way to bind the grid is in &lt;strong&gt;OnInitializeDataSource&lt;/strong&gt; event and using&lt;/p&gt;
&lt;p&gt;e.DataSource = "your database". We didn't recommended to use WebGrid.DataSource and WebGrid.DataBind.&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Julia&lt;/p&gt;</description></item><item><title>Webgrid displaying hierarchical data by databinding in code behind</title><link>http://www.intersoftsolutions.com/Community/WebGrid/Webgrid-displaying-hierarchical-data-by-databinding-in-code-behind/</link><pubDate>Wed, 20 Jan 2010 11:19:06 GMT</pubDate><dc:creator>jcrendulic</dc:creator><description>&lt;p&gt;Ok, so if I return one Dataset with all my data.  It still does not work.  I have &lt;span style="font-size: 13px; color: #ff0000"&gt;&lt;span style="font-size: 13px; color: #ff0000"&gt;Hierarchical&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
Hierarchical&lt;span style="font-size: 13px; color: #0000ff"&gt;&lt;span style="font-size: 13px; color: #0000ff"&gt;="true"&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 13px"&gt; &lt;/span&gt;&lt;span style="font-size: 13px; color: #ff0000"&gt;&lt;span style="font-size: 13px; color: #ff0000"&gt;HierarchicalMode&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 13px; color: #0000ff"&gt;&lt;span style="font-size: 13px; color: #0000ff"&gt;="LoadOnDemand" set.&amp;nbsp; Do you have an example of how to do in the code behind?&amp;nbsp; I have ...&lt;/span&gt;&lt;/span&gt;

&lt;p&gt;&lt;span style="font-size: 13px; color: #0000ff"&gt;&lt;span style="font-size: 13px; color: #0000ff"&gt;&lt;span style="font-size: 13px"&gt;WebGrid1.DataSource = LoadData(&lt;/span&gt;&lt;span style="font-size: 13px"&gt;);&lt;/span&gt; &lt;p&gt;&lt;span style="font-size: 13px"&gt; WebGrid1.DataBind();&lt;/span&gt;&lt;/p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: 13px"&gt;&amp;nbsp;WebGrid1.DataBind();&lt;/span&gt;&lt;/p&gt;</description></item><item><title>Webgrid displaying hierarchical data by databinding in code behind</title><link>http://www.intersoftsolutions.com/Community/WebGrid/Webgrid-displaying-hierarchical-data-by-databinding-in-code-behind/</link><pubDate>Wed, 20 Jan 2010 05:22:09 GMT</pubDate><dc:creator>julia</dc:creator><description>&lt;p&gt;Hi Jocelyn,&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;I am sorry but it's not possible to use different dataset for parent and child in hierarchical WebGrid because there will be no relation between parent and child table.&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Julia&lt;/p&gt;</description></item><item><title>Webgrid displaying hierarchical data by databinding in code behind</title><link>http://www.intersoftsolutions.com/Community/WebGrid/Webgrid-displaying-hierarchical-data-by-databinding-in-code-behind/</link><pubDate>Tue, 19 Jan 2010 16:28:05 GMT</pubDate><dc:creator>jcrendulic</dc:creator><description>&lt;p&gt;Do you have an example of how to bind to the child grid in the code behind page.  I have 2 different data sets, one for the parent table and one for the child table in the webgrid.  How do I bind to the child table in the code behind page?  This is what I have for the parent table it works, but the child table is not loaded...&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;&lt;span style="font-size: 13px"&gt;WebGrid1.DataSource = LoadData(&lt;/span&gt;&lt;span style="font-size: 13px"&gt;);&lt;/span&gt; 

&lt;p&gt;&lt;span style="font-size: 13px"&gt;&amp;nbsp;WebGrid1.DataBind();&lt;/span&gt;&lt;/p&gt;</description></item></channel></rss>