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
55
Bind Ultragrid to a dataset with multiple datatables
posted

I am trying to bind a dataset with multiple datatables to an ultragrid. But i see that only the first datatable in the dataset is bound to the ultragrid. Please advise on what i am doing wrong here. Here is the code snippet.

DataSet ds = new DataSet(); 

DataTable dt1 = CreateDataTable("Table1"); 

ds.Tables.Add(dt1); 

DataTable dt2 = CreateDataTable("Table2"); 

ds.Tables.Add(dt2); 

grid.DataSource = ds;

  • 53790
    posted

    Hello Kartheek,

    Looking at the provided code, I see that you didn`t create relations between your tables.

    DataRelation dr1 = new DataRelation("DR1", dt1.Columns["Id"], dt2.Columns["ParentId"], false);

    DataRelation dr2 = new DataRelation("DR2", dt2.Columns["Id"], dt3.Columns["ParentId"], false);

    ds.Relations.Add(dr1);

    ds.Relations.Add(dr2);

    ultraGrid1.DataSource = ds;

    I made small sample for you. Please take a look there for more details and let me know if you have any questions.

    Regards