Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Basic binding question
Message
General information
Forum:
ASP.NET
Category:
Forms
Title:
Basic binding question
Miscellaneous
Thread ID:
01459508
Message ID:
01459508
Views:
94
(this is a Compact Framework app, but I don't think that should make a difference).

This question comes from my almost complete lack of any .NET WinForm experience in CRUD apps.

I've got a simple WinForms app that has a pageframe with an incremental search and grid on one page. On the other page is another grid and controls which show the details of the grid (this is actually a sub-pageframe for space reasons).

When the user searches or select a grid item, I requery the detail based on the current parent selection.
var result = this.BuildingBO.GetByAddress(addressPk);
this.BindBuilding(result);
this.grdBuilding.DataSource = result;

if (result.Rows.Count > 0)
   this.HighlightRow(this.grdBuilding, 0);
BindBuilding does my data binding:
this.txtBuilding.DataBindings.Clear();
this.txtBuilding.DataBindings.Add("Text", table, "cBuildingName");
// Just store it off it make it easy to access and don't have to do it through DataContext.
this.m_buildingCurrencyMgr = (CurrencyManager)this.BindingContext[table];
this.m_buildingCurrencyMgr.Position = 0;
This all appears to work, except under a few scenarios:

1. If there is only 2 items in the child table, when I select the second item the controls do NOT sync with the grid. If there are more it seems to sync fine.
2. I only noticed this while I was trying to add a new record to the child table and sync the controls to this new record. Not sure if the two issues are one in the same problem. When I create the new record I wasn't able to get the child controls to sync to the new record position:

When I create a new record I'm doing this:
// Left out code which grabs the DataTable reference
var buildingRowCount = buildingTable.Rows.Count;
var row = buildingTable.NewBuildingRow();
row.cAddressFk = addressRow.cAddressPk;
row.cBuildingPk = Guid.NewGuid();
buildingTable.AddBuildingRow(row);
this.m_buildingCurrencyMgr.Position = buildingRowCount;
this.m_buildingCurrencyMgr.Refresh();
I'm sure I'm missing something simple here.
-Paul

RCS Solutions, Inc.
Blog
Twitter
Next
Reply
Map
View

Click here to load this message in the networking platform