Page 1 of 1

A problem in master-detail with innerForm technology

Posted: Sat 01 May 2010 06:45
by mahmoodi_sm
Dear Sir/ Madam,
I have a form with two master-detail grid that works correctly when SqlDataTables are in same form.
But when I link the grids to SqlDataTables in another form with innerForm Tecnology it does not work. When I move in master grid, detail grid does not change.
Best regards.

Posted: Thu 06 May 2010 13:53
by StanislavK
Please check that the form with the referenced data table is created before the form, from which it is referenced. Also, you may send us a small test project so that we are able to reproduce and investigate the issue.

Posted: Sun 09 May 2010 08:15
by mahmoodi_sm
Thanks lot for your reply.
The form with the referenced data table is created before the form that display data.

I create a sample project with two form. Form2 for two master-detail SqlDataTables and Form1 for two DataGridViews.
In Form2 the ParentRelation property of sqlDataTable2 (detail table) is set to sqlDataTable1 and it's related fields.
This is significant code of Form2:

Code: Select all

    partial class Form2
    {
        private void InitializeComponent()
        {
           . . .

            this.sqlDataTable1.Connection = this.sqlConnection1;
            this.sqlDataTable1.Name = "sqlDataTable1";
            this.sqlDataTable1.Quoted = true;
            this.sqlDataTable1.SelectCommand = this.sqlSelectCommand1;
            this.sqlDataTable1.TableName = "sqlDataTable1";
            this.sqlDataTable1.Owner = this;
            this.sqlDataTable2.Connection = this.sqlConnection1;
            this.sqlDataTable2.Name = "sqlDataTable2";
            this.sqlDataTable2.ParentRelation = new  Devart.Common.ParentDataRelation(this.sqlDataTable1, new string[] {
            "OrderID"}, new string[] {
            "OrderID"});
            this.sqlDataTable2.Quoted = true;
            this.sqlDataTable2.SelectCommand = this.sqlSelectCommand2;
            this.sqlDataTable2.TableName = "sqlDataTable2";
            this.sqlDataTable2.Owner = this;
            this.sqlConnection1.ConnectionString = "Data Source=.;Initial Catalog=crm_demo;Integrated Security=False;Password" +
                "=1;Persist Security Info=True;User ID=sa;Application Name=\"dotConnect for" +
                " SQL Server\";";
            this.sqlConnection1.Name = "sqlConnection1";
            this.sqlConnection1.Owner = this;
            this.sqlSelectCommand1.CommandText = "select * from Orders";
            this.sqlSelectCommand1.Connection = this.sqlConnection1;
            this.sqlSelectCommand1.Name = "sqlSelectCommand1";
            this.sqlSelectCommand1.Owner = this;
            this.sqlSelectCommand2.CommandText = "select * from [order Details]";
            this.sqlSelectCommand2.Connection = this.sqlConnection1;
            this.sqlSelectCommand2.Name = "sqlSelectCommand2";
            this.sqlSelectCommand2.Owner = this;
        }
    }
}

And in Form1 I write:

Code: Select all

        
         public Form1(Form2 form2)
        {
            InitializeComponent(form2);
            
            dataGridView1.DataSource = form2.sqlDataTable1;
            dataGridView2.DataSource = form2.sqlDataTable2;

            form2.sqlDataTable1.Open();
            form2.sqlDataTable2.Open();
        }
I run the program. Form1 was opened and data on Form1 are shown but moving on dataGridView1 (master grid) does not change the dataGridView2 (detail grid)'s data !

Posted: Tue 11 May 2010 12:56
by StanislavK
We've reproduced the issue. We will investigate the problem and notify you about the results as soon as possible.

Posted: Fri 21 May 2010 16:25
by StanislavK
We have investigated the problem. The scheme you are interested in cannot be implemented using the Interform technology. The reason is that two different CurrencyManager objects are used on forms Form1 and Form2 for the master grid to master data table binding, and these CurrencyManager instances may point to different positions in master grid. As actually the instance on Form2 is used, changing of the selected row in the master grid will not affect the detail grid.

The only possible workaround is to place the master grid to the form where the master data table is located.

Posted: Sun 20 Jun 2010 09:51
by mahmoodi_sm
Thanks lot.
Is it possible to solve this problem by using two DataLinks between SqlDataTables and DataGridViews?

Posted: Mon 21 Jun 2010 18:07
by StanislavK
You are right: you can set the parent/child relation for SqlDataTables and use two DataLinks for binding data tables to grids. In this case, both DataLinks should have the Synchronized property set to true.