Master Detail with two DataGrids

  • Thread starter Thread starter Mauricio
  • Start date Start date
M

Mauricio

I have a form with 2 DataGrids.
The first is bound with a parent table and the second is
bound with a child table. The update and delete rules of
the relation are Cascade.
When I change a parent's key column value and after I
click on the child DataGrid, the child DataGrid becomes
empty. Now, if I changed the parent's key column value and
click on another parent's row and after click on child
DataGrid, it's ok.
What do I need to do?
 
Hi Mauricio,
I can repro your problem, it seems the key value in the child datagrid
didn't get updated after the key value changed,I'm researching on it to see
if there is a work around to this. I'll update this issue as soon as I get
some result.
Thanks!

Best regards,

Ying-Shen Yu [MSFT]
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security

This posting is provided "AS IS" with no warranties and confers no rights.
You should not reply this mail directly, "Online" should be removed before
sending, Thanks!
 
Hi Mauricio,

I'm still researching on your problem, it seems the child datagrid didn't
get updated correctly, if you call the Refresh method of the parent table's
currency manger, the child datagrid will show data correctly. I'm now
involving more people on this issue, I appreciate you patience when we look
into it, I'll reply to this thread as soon as I have some update to you.
Thanks!

Best regards,

Ying-Shen Yu [MSFT]
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security

This posting is provided "AS IS" with no warranties and confers no rights.
You should not reply this mail directly, "Online" should be removed before
sending, Thanks!
 
Hi Mauricio,
You may get around this problem follow this KB article:
<BUG: A New Record That Is Added to a Parent DataGrid Control Does Not
Populate the Foreign Key Column in the Child DataGrid Control>
http://support.microsoft.com/?id=816227
This article is for adding a new record case, but as my test, the work
around also applies for modifying a primary key column.
Does it solve your problem?

Best regards,

Ying-Shen Yu [MSFT]
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security

This posting is provided "AS IS" with no warranties and confers no rights.
You should not reply this mail directly, "Online" should be removed before
sending, Thanks!
 
Here is some code snippet, I hope it's helpful to you.
<code>
private void Form1_Load(object sender, System.EventArgs e)
{
oleDbDataAdapter2.Fill(dataSet11);
oleDbDataAdapter1.Fill(dataSet11);
dataSet11.Tables["ParentTableName"].RowChanged += new
DataRowChangeEventHandler(Form1_RowChanged);
}

private void Form1_RowChanged(object sender, DataRowChangeEventArgs e)
{
// Get the Currency Manager
CurrencyManager myCurrencyManager =
(CurrencyManager)this.BindingContext[dataSet11, "ParentTableName"];
// Refresh the Currency Manager
myCurrencyManager.Refresh();
}
</code>
Best regards,

Ying-Shen Yu [MSFT]
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security

This posting is provided "AS IS" with no warranties and confers no rights.
You should not reply this mail directly, "Online" should be removed before
sending, Thanks!
 
Hi Ying-Shen Yu [MSFT],
This code resolved the problem.
Thanks.
Best Regards,

Mauricio (Brazil)
ControlBase - Automation Systems
-----Original Message-----
Here is some code snippet, I hope it's helpful to you.
<code>
private void Form1_Load(object sender, System.EventArgs e)
{
oleDbDataAdapter2.Fill(dataSet11);
oleDbDataAdapter1.Fill(dataSet11);
dataSet11.Tables["ParentTableName"].RowChanged += new
DataRowChangeEventHandler(Form1_RowChanged);
}

private void Form1_RowChanged(object sender, DataRowChangeEventArgs e)
{
// Get the Currency Manager
CurrencyManager myCurrencyManager =
(CurrencyManager)this.BindingContext
[dataSet11, "ParentTableName"];
// Refresh the Currency Manager
myCurrencyManager.Refresh();
}
</code>
Best regards,

Ying-Shen Yu [MSFT]
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security

This posting is provided "AS IS" with no warranties and confers no rights.
You should not reply this mail directly, "Online" should be removed before
sending, Thanks!

.
 
Back
Top