Note that there are some explanatory texts on larger screens.

plurals
  1. POBind datagrid to a table and display fields from parent tables
    primarykey
    data
    text
    <p>What is the best strategy to bind the datagrid in the following scenario in WinForms application. Let say, I have a strongly typed dataset with tables:</p> <pre><code>Table1 (T1_ID, T1_VALUE) &lt;--* Table2 (T2_ID, T1_ID, T2_VALUE) &lt;--* Table3(T3_ID, T2_ID, T3_VALUE) </code></pre> <p>I want to bind a datagrid to Table3, and display fields from Table2 and Table1, and have ability to filter, sort by all columns:</p> <pre><code>T3_VALUE | T2_VALUE | T1_VALUE </code></pre> <p>What is the common binding approach in such cases? </p> <p>I see the following alternatives:</p> <ol> <li><p>add calculated columns: <br/> <code>Table2.T1_VALUE = PARENT(T2_T1).T1_VALUE</code> <br/> <code>Table3.T2_VALUE = PARENT(T3_T2).T2_VALUE</code> <br/> <code>Table3.T1_VALUE = PARENT(T3_T2).T1_VALUE</code> <br/> where T2_T1, T3_T2 - relation names. <br/> This seems to be the right way to go, but I am concerned by the polluting the clean data model with redundant calculated columns needed only for UI purposes (elsewhere in code I would still use <code>Table3Row.Table2Row.Table1Row.T1_VALUE</code></p></li> <li><p>Use Linq to query the dataset and get columns from different tables But in this case, the grid will not be able to write data to table3 and also sort.</p></li> <li><p>Bind grid to Table3 and handle events that render the cells, and output the values from parent tables there. The grid can write to Table3, but can't sort (I am using syncfusion grid, but I don't think it makes any difference)</p></li> <li><p>Implement a View that could display data from multiple tables, and update the main table. I didn't dig in this direction, it's seems to be too complicated. Is it possible?</p></li> </ol> <p>As I have pointed, using calculated columns solves all problems, and seems the most easy way to solve it. But maybe there is more elegant and correct approach.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload