If I fill a dataset via tableadpaters with several tables and their schema and assign the dataset to a bindingsource, is it possible to give the bindingsource to the grid datasource and one of the table names to the grid datamember and have it automatically show the hierarchy of the tables assuming the proper constraints and tables were defined? I can do this with a typed dataset sample but notice the grid wizard defined all the bands. In the code where I would like to get the grid to work in a hierarchial fashion, I am using a regular dataset and am not defining bands as I do not necessarily know how many there on a given table and would rather have the grid figure that out rather than have to do it in my code. Is this sort of thing possible or must I define all the bands? Thanks, Dave
Hi,
I'm sorry, but I'm not really clear on the distinction you are making.
If you bind the grid to a DataSource, the grid will automatically read the data structure from that data source and build all of the bands and columns as provided by that data source. You do not have to set up any bands in the grid manually. Is that what you mean?
Yes. I now found the SetDataBinding method so use it instead but I still am getting no bands, just the top level datatable. Here is what I do:
myBindingSource.DataSource = myDataSet;myGrid.SetDataBinding(myBindingSource, myDataTableString, false, false);
and cannot drill down to any child tables. Is there something else I need to set to allow the hierarchical display? This works if I let the wizard do everything against this same data in a test sample. I have added the data and schema to the dataset so all the relations are there.
Thanks, Dave
Thanks Mike. What about the issue of the child being involved in a Many to Many relaitonship directly or further down the line. Is that a show stopper or not? Dave
I wrote a simple test where I brought in all my tables to a dataset and cannot get any of them to go hierarchical even having set multiband and calling SetBinding manually rather than configure anything through the wizard. So...
1. is setting DataMember to a particular table that would hopefully be displayed hierarchically affected by other relations that have nothing to do with that table if they are in the dataset?
2. Would in fact a child table having a Many to Many relationship with yet another table disable the hierarchy?
I created two samples using a pared down dataset that has only child relationships and no many to many tables. One uses a typed dataset and works and the other I load the data manually and does not. The main difference is the typed dataset demo has all the band definitions and the other does not and I depend on the ultragrid to discover the data hierachy dynamically. I even set the multiband property. So obviously not the data. Problem has to be that I missed setting something on the grid or the grid is not discovering the hierarchy dynamically. I do not define relationships manually but rather do a FillSchema on each table while constraints are on. Any other ideas or suggestions? Can you point me to an example of a grid demo that dynamically creates multiple bands based on a non typed dataset? Thanks, Dave
Well I got this working only by adding the Dataset Relations myself and can say that having a Many to Many table constraint in the database and as a dataset Relation does not matter as the child cascading happens fine 3 levels deep and works with multiple child tables at a given level. I originally thought that the DataAdapter FillSchema would have added the table constraints as Relations to the Dataset and was quite surprised it did not as debugging showed 0 Relations. Would appreciate any comments anyone might have on this. Thanks, Dave
You have to add the relations yourself. FillSchema on the DataAdapter does not do that for you.