Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
400
WebHierarchicalDataGrid binding through code
posted

Hello,

I am attempting to bind my WebHierarchicalDataGrid through code using LinqToSQL methods. The parent grid displays and when I click arrow to view the child view, the following error message displays: 

[Exception]: DataView has no DataSourceID or DataSource set.

I have the following code to create and bind my DataGrid, DataViews and DataRelations in my Page_Load event handler:

                //

                //create the OrderHeaders view

                Infragistics.Web.UI.DataSourceControls.DataView view = new Infragistics.Web.UI.DataSourceControls.DataView();

 

                //set the properties of the OrderHeaders view

                view.ID = "OrderHeadersDataView";

                view.DataSource = scRepository.GetOrders(customerNo);

 

                this.WebHierarchicalDataSource1.DataViews.Add(view);

 

                //

                //create the OrderDetails view

                view = new Infragistics.Web.UI.DataSourceControls.DataView();

 

                //set the properties of the OrderDetails view

                view.ID = "OrderDetailsDataView";

                view.DataSource = scRepository.GetOrderDetails(customerNo);

 

                this.WebHierarchicalDataSource1.DataViews.Add(view);

 

 

                Infragistics.Web.UI.DataSourceControls.DataRelation dr = new Infragistics.Web.UI.DataSourceControls.DataRelation();

                dr.ParentDataViewID = "OrderHeadersDataView";

                dr.ParentColumns = new string[] { "OrderNo" };

                dr.ChildDataViewID = "OrderDetailsDataView";

                dr.ChildColumns = new string[] { "OrderNo" };

                this.WebHierarchicalDataSource1.DataRelations.Add(dr);

 

                this.whgOrders.DataSourceID = this.WebHierarchicalDataSource1.ID;

                this.whgOrders.DataBind();

 

And markup:

    <ig:WebHierarchicalDataGrid ID="whgOrders" runat="server" Height="450px" Width="600px" AutoGenerateColumns="False" AutoGenerateBands="true">

        <Columns>

            <ig:BoundDataField DataFieldName="OrderNo" Header-Text="Order No" Key="OrderNo" />

            <ig:BoundDataField DataFieldName="CustomerPoNo" Header-Text="Cust PO" Key="CustomerPoNo" />

            <ig:BoundDataField DataFieldName="RevisedDueDate" Header-Text="Due Date" Key="RevisedDueDate" DataFormatString="{0:d}" />

        </Columns>

        <Bands>

            <ig:Band AutoGenerateColumns="false" DataKeyFields="OrderNo">

                <Columns>

                    <ig:BoundDataField DataFieldName="LineNum" Header-Text="Line No" Key="LineNum" />

                    <ig:BoundDataField DataFieldName="PartNo" Header-Text="Part No" Key="PartNo" />

                    <ig:BoundDataField DataFieldName="BuyQtyDue" Header-Text="Qty" Key="BuyQtyDue" DataFormatString="{0}" />

                    <ig:BoundDataField DataFieldName="RevisedDueDate" Header-Text="DueDate" Key="RevisedDueDate" DataFormatString="{0:d}" />

                </Columns>

            </ig:Band>

        </Bands>

    </ig:WebHierarchicalDataGrid>

 

    <ig:WebHierarchicalDataSource ID="WebHierarchicalDataSource1" runat="server">

    </ig:WebHierarchicalDataSource>

 

What am I doing wrong?

 

Thanks

Steve

 

Parents Reply Children
No Data