CLR: .Net / Mono / Boo / Otros CLR > VB .NET
Relacion General-detalle
(1/1)
senzao18:
Hola alguien tiene un ejemplo de relacion entre tablas
General-Detalle, mediante dos datagrid ocupo que la posicionarme en le registro del datagrid general, me salga su detalle en otro datagrid, espero y me entiendan :D.
sergiotarrillo:
cheka este codigo, generas un detalle(dataview), apartir de un index seleccionando del padre!:
--- Código: Text ---'Create DataRelation: each publisher publishes many titlesDim dr As DataRelationDim parentCol As DataColumnDim childCol As DataColumnparentCol = ds.Tables("Customers").Columns("CustomerID")childCol = ds.Tables("Orders").Columns("CustomerID")dr = New DataRelation("CustOrders", parentCol, childCol)ds.Relations.Add(dr)// Create DataRelation: each publisher publishes many titlesDataRelation dr;DataColumn parentCol;DataColumn childCol;parentCol = ds.Tables["Customers"].Columns["CustomerID"];childCol = ds.Tables["Orders"].Columns["CustomerID"];dr = new DataRelation("CustOrders", parentCol, childCol);ds.Relations.Add(dr);
--- Código: Text ---Dim parentTableView As New _DataView(ds.Tables("Customers"))Dim currentRowView As DataRowView = _parentTableView(dgCustomers.SelectedIndex)dgChild.DataSource = _currentRowView.CreateChildView("CustOrders")dgChild.DataBind()DataView parentTableView = newDataView(ds.Tables["Customers"]);DataRowView currentRowView =parentTableView[dgCustomers.SelectedIndex];dgChild.DataSource =currentRowView.CreateChildView("CustOrders");dgChild.DataBind();
senzao18:
Gracias segio.
Navegación
Ir a la versión completa