Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
660
2 UltrawinnGrid needs to bind with Same Datasource (DataSet)
posted

Hi All,

Is there anyway to bind the same Datasource(dataset) to 2 different UltraWinGrid on the same form.

DataSet has 4 tables, relation1 is between Table1 and Table2 and relation2 is between Table3 and table4.

I want to Bind the relation1 to UltraGrid1 and relation2 to UltraGrid2.

I already created the deign time bands for both the grid.

Any Suggestions/pointer please

With Thanks & Regards

Amjath

Parents
No Data
Reply
  • 48586
    posted

    Hello,

     

    Yes it is possible to bind UltraGrid to such way, so you should set as DataSource  of the grid your dataset and also you should specify DataMember of the grid to the parent table of the relation which you want to display. Here is simple code snipped that creates dataset with 4 tables and two grids that display relations of the dataset:

     

    DataSet ds = new DataSet();

     

                DataTable t1 = ds.Tables.Add("table1");

                t1.Columns.Add("id", typeof(int)).AutoIncrement = true;

                t1.Columns.Add("Text", typeof(string)).Expression = "'table1 row'+[id]";

     

                DataTable t2 = ds.Tables.Add("table2");

                t2.Columns.Add("id", typeof(int)).AutoIncrement = true;

                t2.Columns.Add("pid", typeof(int));

                t2.Columns.Add("Text", typeof(string)).Expression = "'table2 row'+[id]";

     

                DataTable t3 = ds.Tables.Add("table3");

                t3.Columns.Add("id", typeof(int)).AutoIncrement = true;

                t3.Columns.Add("Text", typeof(string)).Expression = "'table3 row'+[id]";

     

                DataTable t4 = ds.Tables.Add("table4");

                t4.Columns.Add("id", typeof(int)).AutoIncrement = true;

                t4.Columns.Add("pid", typeof(int));

                t4.Columns.Add("Text", typeof(string)).Expression = "'table4 row'+[id]";

     

                for (int i = 0; i < 5; i++)

                {

                    DataRow row1 = t1.Rows.Add();

                    DataRow row3 = t3.Rows.Add();

                    for (int j = 0; j < 5; j++)

                    {

                        t2.Rows.Add(null, row1["id"]);

                        t4.Rows.Add(null, row3["id"]);

                    }

                }

     

     

                ds.Relations.Add("t1 to t2", t1.Columns["id"], t2.Columns["pid"]);

                ds.Relations.Add("t3 to t4", t3.Columns["id"], t4.Columns["pid"]);

     

                ultraGrid1.DataSource = ds;

                ultraGrid1.DataMember = "table1";

     

                ultraGrid2.DataSource = ds;

                ultraGrid2.DataMember = "table3";

     

    Please let me know if you have any further questions.

Children