I have a multiband grid and bound the grid.DataSource to a bindingSource. The grid rows are displayed in correct hierachical form.
My grid would display band[0] to band[3]. For layout reasons I like band[2] and band[3] data display in other controls on my form. For every band (=dataTable) I have a bindingSource with dependencies over foreign key relation in my dataSet and I use this for the bindingSource.DataMember. Everything like it should be, I guess.
But if I select grid child rows in band[1] my dependent data are not displayed corresponding to the grid row.
Do I need assign the bindingSource assign to the grids band[1]? I looked for a property such like grid.displayLayout.Bands[1].dataSource but this is not possible.
Thanks for any help.
Markus
Hi Markus,
The DotNet BindingManager will handle this for you automatically, as long as the controls are bound property to the correct data sources and as long as all of the controls have the same BindingContext.
By default, the controls get their BindingContext based on their containing control. So if all of the controls are in the same container, then you probably just have to mess around with the bindings a little. I don't think we have any documentation on this, since it's really nothing to do with our controls, specifically, but Microsoft must document this somewhere.
Hello Mike,
The data structure has 4 bands. The top two bands are displayed in the first grid in Multiband mode. Band[2] ist displayed in a SingleBand Grid and Band[3] is displayed in another SingleBand grid.
Every Grid is in a seperate UltraGroupBox but in the same Form. The grids are bound to a DataSet with 4 tables and I use 4 BindingSources with relations specified. This should be ok, since I did not have had any problems with this part so far.
But, to reflect dependencies in the depending grids I must use a piece of code like this:
long parentId = 0; if ( this.GridAccLink.ActiveRow.Band.Index == 1 ) parentId = (long)this.GridAccLink.ActiveRow.Cells["AccountLinkDefId"].Value; this.bsAccountOperation.Filter = string.Format( "AccountLinkDefId = {0}", parentId ); this.GridOperation.Refresh();
Is the containing control the problem or di I miss something else?
Regards. Markus
I could not solve the problem so far. Setting the grid2.BindingContext = grid1.BindingContext makes no difference.
If I place a editControl to the form (into the same groupBox as the grid) and bind the value property to the Id-column of Band[1], the displayed Id does not change when activating different rows in the grids band[1]. It always shows the same Id. Does the active row not change the position?
Where is the problem? I have setup the binding sources in the designer.
Best Regards. Markus
The grid synchronizes the current row of the BindingManager by default. You might want to check to make sure you aren't turning this off, though. Check the SynchWithCurrencyManager property on the grid and make sure it's not being set to False.
If that does not help and you are sure the controls have the same BindingContext, then as I was saying above, you might have to play around with how you are binding. There are multiple ways to bind to the same field.
There's a similar discussion about this here:
How to sync a textbox with a child record in the ultragrid? - Infragistics Community
Hi Mike,
sorry about, but I can't find the problem. The SynchWithCurrencyManager property is set to True for all grids.
I have no Bindings set from code, because I have setup my BindingSources from the designer. The situation looks not too difficult to me but it does not work. My DataSources and bindings looks like this:
My DataSet contains 4 tables (Table1, Table2,.......Table4). Each Table has a one to many relationship to the next table defined in the DataSet. For each of the tables I have a BindingSource on the form.
BindingSource1.DataSource = myDataSet; BindingSource1.DataMember = Table1;
BindingSource2.DataSource = BindingSource1; BindingSource2.DataMember = FK_Table2_Table1;
........
BindingSource4.DataSource = BindingSource3; BindingSource4.DataMember = FK_Table4_Table3;
Grid1 is bound to BindingSource1 and shows two Bands with data from Table1 and Table2. Other Bands are set to hidden.
Grid2 is Bound to BindingSource3 in SingleBand mode.
Grid3 is Bound to BindingSource4 in SingleBand mode.
What I expect is that selecting a row in Grid1.Band[1] (-> Table2 Data) Grid2 shows the depending data of Table3. Debugging the code shows me that new rows are created with correct foreign key values but depending data are still not displayed. Turning all Bands to visible in Grid1 I see the depending data but they are not shown in grid two??
I have also read the discussion you mentioned above, but as long as I just use the grids I don't have any more bindings to add. If the grid works, I can go a step further.
Do you have any ideas what I can do or I must proceed with some "workaround code" etc.
Best regards. Markus
I can you give some more information. I have placed a new grid on the form, bound to a datasource like described above but only two binding sources. The grid has therefore 2 bands. Furthermore I have bound two ultraNumericEditor to the primary keys of the bands.
Only changing the active row of the grid in the first band are reflected in the bound edit controls. The Id of the child rows is always the first row-Id.
I'm using version 9.2.20092.2058. Is this a bug?
mac_swit said: I can you give some more information. I have placed a new grid on the form, bound to a datasource like described above but only two binding sources. The grid has therefore 2 bands. Furthermore I have bound two ultraNumericEditor to the primary keys of the bands. Only changing the active row of the grid in the first band are reflected in the bound edit controls. The Id of the child rows is always the first row-Id. I'm using version 9.2.20092.2058. Is this a bug?
How are you binding the second UltraNumericEditor. My guess is that you are binding it to the child table in the DataSource and not to the Relationship, which is what really represents the child band.
All of this is handled by the BindingManager in DotNet, though, it's really nothing specifically to do with the NetAdvantage controls, so it's not a bug - unless the grid is somehow not synchronizing the position of the BindingManager. But that's been working fine for 10 years, so it's unlikely that it broke recently. :)
I'm not sure, you might want to check with Microsoft and see if they have a better solution. I can't claim to be an expert on the BindingSource.
The only way I could get this to work was to use the same BindingSource for all three controls:
this.bsParent.DataSource = this.ds; this.bsParent.DataMember = "Parent"; this.ultraGrid1.DataSource = this.bsParent; // Bind a Numeric Editor to the Price field in the child band. this.ultraNumericEditor1.DataBindings.Add("Value", this.bsParent, "Parent-Child.Price"); // Bind the child grid to the entire child list. this.ultraGrid2.SetDataBinding(this.bsParent, "Parent-Child");
I have modified your sample using BindingSources as I told you. Now you can see that selecting band[1] in grid1 does not reflect changes in grid2.
Can you explain me how to set the BindingSource properties DataSource and DataMember correctly that everything works. If I set the DataMember property as you did, I'm running into compile error "member not found in the source".
Best Regards
I'm attaching a sample here that binds both a grid and an UltraNumericEditor to some child data.
No I did not bound to the child data table. The BindingSource of Band[1] has the BindingSource of Band[0] as DataSource property and the relation (FK_Table2_Table1) as DataMember property defined. The NumericEditor is then bound to the ID-column of the BindingSource of Band[1].
I have found some discussions here about the problem:
http://devcenter.infragistics.com/Support/KnowledgeBaseArticle.Aspx?ArticleID=1753
But implementing this, does not solve the problem. Selecting rows on band[1] are not reflected. My workaround is to set a filter on the binding source with the parent-ID in the Grid_AfterSelectChange event.
this.myBindingSource.Filter = string.Format( "AccountId = {0}", parentId );
Since I don't have the same situation in a other form or project, I can not compare. Maybe I setup a small test project to figure out. But for now I have wasted lot of time working on this and I use my workaround. If I have a test project I will send you this later.