开发者

Reading master and child tables from a combined table

Am using Infragistics UltraWinGrid.UltraGrid control to show hierarchical data in my .Net 3.5 winforms app. From my middle tier, I get a datatable which has combined data for both the master and child tables. I can get the data for child table using group by clause.

Am using DataRelation as below, and then I bind a local dataset variable containing master and child table to the grid.

ds.Tables.Add(tableMaster); 
ds.Tables.Add(tableChild);

DataRelation reln = new DataRelation("MyReln", ds.Tables[0].Columns[colName], ds.Tables[1].Columns[colName], false);
ds.Relations.Add(reln); 

ds.AcceptChanges(); 

this.ultraGrid.DataSource = ds;
开发者_JAVA技巧

My query is, what would be the fastest way to read this tableMaster and tableChild from the consolidated datatable above?

Thanks.


Perhaps you should just store a JOIN result in your DataGridView control:

string sql = "SELECT * " +
  "FROM TableMaster M " +
  "LEFT JOIN TableChild C ON M.ColName=C.ColName";
// SelectDataTable would be your collection method
DataTable bigTable = SelectDataTable(sql);
this.ultraGrid.DataSource = bigTable.DefaultView;

This way, your data would always be available.

EDIT: Of course, you could always just add bigTable to your DataSet and access it whenever necessary.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜