Exception in datagrid when bound to related view
-
hey all, i have a dataset with three related tables in it. Table_1 -> 1-n Table_2 -> 1-n -> Table_3 I build a treeview with Table_1 and show the related rows of Table_2 in a Datagrid (grid_1). By selecting a row in the grid i show the details of that row and all related rows of Table_3 in another grid (grid_2). If i use perfmon to watch all exceptions of my application i get 5 Exceptions each time i select another node in the treeview (each node represents a datarow of Table_1). If I don't assign the second grid with a datasource (in my case a dataview of Table_1) i get no exceptions. The difference between grid_1 and grid_2 is the assignment of the datasource. The datasource of grid_1 will be assigned in the AfterNodeSelected event of the treeview after positioning the currencymanager tho the right position. the datasource of grid_2 will be assigned at initialization time.
Private Sub trvProducts_AfterSelect(ByVal sender As Object, ByVal e As System.Windows.Forms.TreeViewEventArgs) Handles trvProducts.AfterSelect If Not Me.trvProducts.SelectedNode Is Nothing Then Dim i As Integer = Me.NavigationView.Find(CType(Me.trvProducts.SelectedNode.Tag, Product.Model.dsProduct.tblProductGroupRow).ID) Me.Grid_1.SuspendLayout() Me.Grid_1.DataMember = "" Me.Grid_1.DataSource = Nothing cmGroup.Position = i Me.Grid_1.DataMember = "tblProductGrouptblProduct" Me.Grid_1.DataSource = NavigationView Me.Grid_1.Refresh() Me.Grid_1.ResumeLayout(True) End If End Sub public Sub New() [...] NavigationView.Table = Me.Dataset.Table_1 Me.Grid_2.DataMember = "tblProductGrouptblProduct.tblProducttblProductPrice" Me.Grid_2.DataSource = NavigationView End Sub
Please Help !! cheers, Bernd