By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,086 Members | 1,875 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,086 IT Pros & Developers. It's quick & easy.

Master-> Detail-> Detail with datagrids

P: n/a
Hello,

I am trying (unsuccessfully) to display a Master-Detail-Detail records. The
problem comes in the second detail grid. The first detail grid is
displaying correctly but it is not controlling the second grid. Here is
some code that I am using to initialize the binding:

txtName.DataBindings.Add("Text", dsFundOwner, "FundOwner.Name")
txtNote.DataBindings.Add("Text", dsFundOwner, "FundOwner.Note")
txtInformationSource.DataBindings.Add("Text", dsFundOwner,
"FundOwner.InformationSource")
txtLocation.DataBindings.Add("Text", dsFundOwner, "FundOwner.LocationState")
txtCountry.DataBindings.Add("Text", dsFundOwner, "FundOwner.Country")
txtFounder.DataBindings.Add("Text", dsFundOwner, "FundOwner.Founder")
txtTotalManaged.DataBindings.Add("Text", dsFundOwner,
"FundOwner.TotalManaged")
txtTotalManagedNotes.DataBindings.Add("Text", dsFundOwner,
"FundOwner.TotalManagedNotes")
txtRaiseNewFund.DataBindings.Add("Text", dsFundOwner,
"FundOwner.ExpectedToRaiseNewFund")
txtNewFundDate.DataBindings.Add("Text", dsFundOwner,
"FundOwner.ExpectedToRaiseNewFundDate")
dgSubsidiaries.DataSource = dsFundOwner
dgSubsidiaries.DataMember = "FundOwner.FundOwner_Subsidiary"

' This grid is not displaying correctly when the dgSubsidiaries record
pointer is changed
dgFunds.DataSource = dsFundOwner
dgFunds.DataMember = "Subsidiary.Subsidiary_Fund"

Any Suggestions?

Thanks,
Dan
Nov 20 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Hi,

Use Datagrid.SetDatabinding. Here is an example which uses the
northwind database.

Dim ds As DataSet

Dim daEmployees As SqlDataAdapter

Dim daOrders As SqlDataAdapter

Dim daOrderDetails As SqlDataAdapter

Dim conn As SqlConnection

Dim strConn As String

Dim strSQL As String

Dim strItem As String

Dim ctrl As Control

For Each ctrl In Me.Controls

If TypeOf ctrl Is DataGrid Then

Dim dg As DataGrid = ctrl

dg.AllowNavigation = False

End If

Next

strConn = "Server = " + Environment.MachineName + "\VSdotNet;"

strConn += "Database = NorthWind;"

strConn += "Integrated Security = SSPI;"

conn = New SqlConnection(strConn)

ds = New DataSet

daEmployees = New SqlDataAdapter("Select * from Employees", conn)

daOrders = New SqlDataAdapter("Select * from Orders", conn)

daOrderDetails = New SqlDataAdapter("Select * from [Order Details]", conn)

daEmployees.Fill(ds, "Employee")

daOrders.Fill(ds, "Orders")

daOrderDetails.Fill(ds, "OrderDetails")

ds.Relations.Add("EmployeeOrder",
ds.Tables("Employee").Columns("EmployeeID"), _

ds.Tables("Orders").Columns("EmployeeID"))

ds.Relations.Add("Order2Details", ds.Tables("Orders").Columns("OrderID"), _

ds.Tables("OrderDetails").Columns("OrderID"))

dgEmployees.SetDataBinding(ds, "Employee")

dgOrders.SetDataBinding(ds, "Employee.EmployeeOrder")

dgOrderDetails.SetDataBinding(ds, "Employee.EmployeeOrder.Order2Details")

Ken

-------------------

"solex" <so***@nowhere.com> wrote in message
news:uu*************@TK2MSFTNGP11.phx.gbl...
Hello,

I am trying (unsuccessfully) to display a Master-Detail-Detail records. The problem comes in the second detail grid. The first detail grid is
displaying correctly but it is not controlling the second grid. Here is
some code that I am using to initialize the binding:

txtName.DataBindings.Add("Text", dsFundOwner, "FundOwner.Name")
txtNote.DataBindings.Add("Text", dsFundOwner, "FundOwner.Note")
txtInformationSource.DataBindings.Add("Text", dsFundOwner,
"FundOwner.InformationSource")
txtLocation.DataBindings.Add("Text", dsFundOwner, "FundOwner.LocationState") txtCountry.DataBindings.Add("Text", dsFundOwner, "FundOwner.Country")
txtFounder.DataBindings.Add("Text", dsFundOwner, "FundOwner.Founder")
txtTotalManaged.DataBindings.Add("Text", dsFundOwner,
"FundOwner.TotalManaged")
txtTotalManagedNotes.DataBindings.Add("Text", dsFundOwner,
"FundOwner.TotalManagedNotes")
txtRaiseNewFund.DataBindings.Add("Text", dsFundOwner,
"FundOwner.ExpectedToRaiseNewFund")
txtNewFundDate.DataBindings.Add("Text", dsFundOwner,
"FundOwner.ExpectedToRaiseNewFundDate")
dgSubsidiaries.DataSource = dsFundOwner
dgSubsidiaries.DataMember = "FundOwner.FundOwner_Subsidiary"

' This grid is not displaying correctly when the dgSubsidiaries record
pointer is changed
dgFunds.DataSource = dsFundOwner
dgFunds.DataMember = "Subsidiary.Subsidiary_Fund"

Any Suggestions?

Thanks,
Dan

Nov 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.