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
725
WebHierarchicalDataSource Vs UltraDataSource?
posted

Hello.

I was wondering what is the web equivelant to the winforms UltraDataSource.

Is it the WebHierarchicalDataSource? And if yes, how can I manually add the bands, childbands etc to this?

Here is the code I'm using to my winforms application:

UltraDataSource datasource = new UltraDataSource();
                  datasource.Band.Columns.Add(this.X_AxisName, typeof(String));
                  UltraDataBand childBand = datasource.Band.ChildBands.Add("cbKey");
                  childBand.Columns.Add(this.Y_AxisName, typeof(String));
                  childBand.Columns.Add(this.DataName, typeof(Int32));
                  childBand.Columns.Add(TotalPercentageString, typeof(Decimal));
                  childBand.Columns.Add(FiltersPercentageString, typeof(Decimal));
                  datasource.Rows.SetCount(xaxisavailabledata.Count);
                  #endregion
                  #region Load data on datasource
                  int noOfFilteredData = GetNoOfTotalFilterdData();
                  int noOfData = 0;
                  decimal posostoTotal;
                  decimal posostoFilters;
                  for (int i = 0; i < xaxisavailabledata.Count; i++)
                  {
                        datasource.Rows[i][0] = GetX_AxisString(xaxisavailabledata[i]);
                        UltraDataRowsCollection childRows = datasource.Rows[i].GetChildRows("cbKey");
                        childRows.SetCount(yaxisavailabledata.Count);
                        for (int j = 0; j < yaxisavailabledata.Count; j++)
                        {
                              noOfData = GetNoOfData(xaxisavailabledata[i], yaxisavailabledata[j]);
                              //if (noOfData > this.LowerDataLimit)
                              //{
                                    posostoTotal = 0.0M;
                                    posostoFilters = 0.0M;
                                    if (this.X_RecordsDataTable.Rows.Count > 0)
                                    {
                                          posostoTotal = (100 * (decimal)noOfData) / ((decimal)this.X_RecordsDataTable.Rows.Count);
                                          posostoTotal = decimal.Round(posostoTotal, 2);
                                    }
                                    if (noOfFilteredData > 0)
                                    {
                                          posostoFilters = (100 * (decimal)noOfData) / ((decimal)noOfFilteredData);
                                          posostoFilters = decimal.Round(posostoFilters, 2);
                                    }
                                    childRows[j][0] = GetY_AxisString(yaxisavailabledata[j]);
                                    childRows[j][1] = noOfData;
                                    childRows[j][2] = posostoTotal;
                                    childRows[j][3] = posostoFilters;
                              //}                             
                        }
                  }
                  #endregion
                  return datasource;

How can I rewrite this code for my web application since there is no UltraDataSource for the asp.net?

Thanks!

  • 3147
    posted

    Hi,

    WebHierarchicalDataSource is not exactly an equivalent to the WinForms UltraDataSource. It is different concept of a data source control. Its purpose is to combine flat data sources (DataViews) and then define DataRelations between them. Then it automatically generates hierarchy based on these relations. For more info you can take a look at our online samples at

    http://samples.infragistics.com/2009.2/WebFeatureBrowser/Default.aspx.

    For your web application you can use WebHierarchicalDataGrid to display the
    data. Since you generate the data manually in the code-behind there is no need to use the
    WebHierarchicalDataSource. You can use directly DataSets or collections of custom objects, here is an example using ArrayLists:


        <ig:WebHierarchicalDataGrid ID="whdgTest" InitialDataBindDepth="1" Width="600px" runat="server">
        </ig:WebHierarchicalDataGrid>


        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                whdgTest.DataSource = GetData();
            }
        }

        private IEnumerable GetData()
        {
            ArrayList data = new ArrayList();

            for (int i = 0; i < 10; i++)
            {
                ArrayList children = new ArrayList();
                data.Add(new
                {
                    X_AxisName = string.Format("x axis data {0}", i),
                    Children = children
                });

                for (int j = 0; j < 3; j++)
                {
                    children.Add(new
                    {
                        Y_AxisName = string.Format("y axis data {0}", j)
                        // etc.
                    });
                }
            }

            return data;
        }

  • 725
    posted

    Anyone? I could really need a hand here to migrate my winforms code to my website...