When binding a datagrid (GridControl) to a table do the following:
- Create a typed dataset class by calling something like myDs.WriteXmlSchema(“D:\MyDataset.xsd”) in a web service web method (assuming the DAL is done on the web service). It will generate and save the schema into the file. Copy the file into the client application project.
- Create a dataset component by dragging the created dataset onto the form. This will create global variable of type MyDataset (say, m_MyDataset).
- Set your GridControl’s DataSource property to m_MyDataset.MY_TABLE_1 and leave DataMember property empty (as opposed to setting DataSource to m_MyDataset and DataMember to MY_TABLE_1).
NOTE: it is not possible to do this step in VS designer. You will need to manually modify MyForm.Designer.vb file.
- If you have another grid control which should display child records, set its DataSource property to the same value (m_MyDataset.MY_TABLE_1) but also specify the relation name in the DataMember property.
WARNING: GetChildRows() method of DataRow class unexpectedly ignores trailing spaces in columns which participate in the relation. The logic behind GridControls does not ignore the spaces. This behaviour may result in situation when GetChildRows() returns an array of child rows which is larger than the number of rows displayed in the child GridControl.