Solved

Programatically Updating  Bound child datagridview

Posted on 2013-05-29
4
422 Views
Last Modified: 2013-06-28
I have two DataGridViews on a form in a parent-child relationsihp. The parent dgv is bound to a BindingSource whose DataSource is a table. The child dgv is bound to a BindingSource whose DataSource is the parent BindingSource and whose DataMember is the relation between the parent and child tables in the DataSet.

Parent Grid (dgvOEntryAdvise)
bindingsource11.DataSource = dsDet.Tables("OIAdviseDetails")
dgvOEntryAdvise.DataSource = bindingsource11

Child Grid ( dgvOSAdvise)
  bindingsource13.DataSource = bindingsource11 'dsDet.Tables("OSAdviseDetails") '
   bindingsource13.DataMember = "FK_OS_OI_Advise"
   dgvOSAdvise.DataSource = bindingsource13


dtOEntry = dsDet.Tables("OIAdviseDetails")  --
table bound to parent dgv (dgvOEntryAdvise)

Dim newrow As DataRow = dtOEntry.NewRow()
newrow.BeginEdit()
 newrow("Caseid") = lngcaseid
 newrow("OCCode") = dgvOIList.CurrentRow.Cells("Occode").Value
 newrow("OCName") = dgvOIList.CurrentRow.Cells("OCName").Value
 newrow("OICode") = dgvOIList.CurrentRow.Cells("OICode").Value
newrow("OIName") = dgvOIList.CurrentRow.Cells("OIName").Value
newrow.EndEdit()
dtOEntry.Rows.Add(newrow)

(Upto this it is working fine)

for some order item in parent grid i want to add programatically few child rows in the child datagrid ...

Pls advise on how to do this
0
Comment
Question by:venkataramanaiahsr
  • 2
  • 2
4 Comments
 
LVL 10

Expert Comment

by:adriankohws
ID: 39214034
When you use parent and child relationship and binding, how are you be able to add rows yourself?

I don't know why you wish to add rows but you can only add them to the binding source and rebind the child datagridview.
0
 

Accepted Solution

by:
venkataramanaiahsr earned 0 total points
ID: 39270288
I could solve it by other means. i got the both parent and child data into single grid by join
statement and it solved my problem
0
 
LVL 10

Expert Comment

by:adriankohws
ID: 39271723
I have no objection against what you said but it isn't a solution. If at the first place you can combine two relationship into one row display, then this question does not stand. There's a reason to have master detail. Imagine one master record can have 30 rows of details, show them in one grid??
0
 

Author Closing Comment

by:venkataramanaiahsr
ID: 39283805
I could solve it by other means. i got the both parent and child data into single grid by join
statement and it solved my problem
0

Featured Post

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question