I have a dataset that contains three tables - A, B1, B2. A stands by itself. B1 and B2 have a relationship. I have two grids on my form - A and B.
Grid A's datasource = Dataset.A and I am not having any issues with the data showing in the grid. Grid B's datasource should be tables B1 and B2. Grid B, however is where I am having a problem. I have tried setting grid B's datasource = Dataset.B and Dataset (by itself).
After setting the datasource for grid B I loop through the bands to hide any tables that are not B1 or B2, which happens to be table A. Once done nothing shows in grid B.
Is there a way to do this with all three tables in the same dataset? The dataset was created as an .xsd file.
Thanks!
Hello,
I have been looking into your requirement and created a small sample in order to demonstrate how such behavior could be achieved. For the purposes of the example I created DataSet with three tables (each one has a unique name) and as you described the first one stands by itself and there is a relation between the other two.
After setting both grids' DataSource property to this DataSet, my suggestion in order to achieve your requirement is to set the DataMember property of each grid to the name of the table you need. Keep in mind that the DataMember property of the grid that contains the tables with a relationship has to be set to the parent table.
public Form1() { InitializeComponent(); DataSet _data = getData(); this.ultraGrid1.DataSource = _data; this.ultraGrid1.DataMember = "table0Name"; this.ultraGrid2.DataSource = _data; this.ultraGrid2.DataMember = "table1Name"; } private DataSet getData() { DataTable table0 = new DataTable("table0Name"); //Add columns and rows DataTable table1 = new DataTable("table1Name"); //Add columns and rows DataTable table2 = new DataTable("table2Name"); //Add columns and rows DataSet set = new DataSet("dataSetName"); //Add tables to the DataSet, create and add the relation between table1 and table2 return set; }
Attached you will find my sample for your reference. Please test it on your side and let me know how it behaves. If this is not an accurate demonstration of what you are trying to achieve please feel free to modify it and send it back to me along with steps to reproduce. Alternatively, if the behavior cannot be replicated please feel free to provide your own sample. Remove any external dependencies and code that is not directly related to the issue, zip your application and attach it in this case.
Having a working sample on my side, which I can debug, is going to be very helpful in finding the root cause of this behavior.
Thank you for your cooperation.
Looking forward to hearing from you.
Sincerely,
Teodosia Hristodorova
Associate Software Developer
3755.UltraGrid_DataSet.zip
That worked PERFECTLY!! Thanks so much Teodosia. I spent so much time on this and was afraid I would need to either create two difference datasets or two instances of the same database but remove the unneeded table(s). This is a way better solution.
I am glad that you find my suggestion helpful.
Thank you for using Infragistics components.
Regards,Teodosia HristodorovaAssociate Software Developer