|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Datagrid binding problemI have a dataset that contain 2 tables and a relationship between them (master detail). I bind this dataset to a form that include some textboxes that bind to the parent record, and a datagrid that is binded to the detailed records. Here is the code: Code: Private Sub FillHeader(ByRef dsDataSet As DataSet) Try txtKey.DataBindings.Add(New Binding("text", dsDataSet , "header.key")) txtNo.DataBindings.Add(New Binding("text", dsDataSet , "header.no")) Catch ex As Exception HandleExceptions(ex) End Try End Sub Code: Private Sub FillLines(ByRef dsDataSet As DataSet) Try dsDataSet.Tables("lines").Columns("key").ColumnMapping = MappingType.Hidden dsDataSet.Tables("lines").Columns("product_id").ColumnName = "Product Id" dsDataSet.Tables("lines").Columns("quantity").ColumnName = "Quantity" dgLines.SetDataBinding(dsDataSet.Tables!lines, "HeaderLines") Catch ex As Exception HandleExceptions(ex) End Try End Sub The sub I use to navigate is (For example I put only the next command): Code: Sub cmdNext() Implements ICommandNext.cmdNext Try bdRecordNavigator = BindingContext(dsHeader, "header") bdRecordNavigator.Position += 1 Catch ex As Exception HandleExceptions(ex) End Try End Sub My problem happens when I navigate between the master records. The textboxes show the correct values, but there is no change in the datagrid. What do I miss here, that this sub will handle the datagrid as well? Thanks Hi,
You need to use datagrid.setdatabinding to get the child grid to only display the filtered records. http://www.vb-tips.com/default.aspx?ID=a1a84750-08df-49b4-8657-7bc3068aca2c http://www.vb-tips.com/default.aspx?ID=3eafa9ea-a906-45ff-aece-e8335682ad3a Ken ----------------- Show quoteHide quote "no" wrote: > Hi all, > > I have a dataset that contain 2 tables and a relationship between them > (master detail). > I bind this dataset to a form that include some textboxes that bind to the > parent record, and a datagrid that is binded to the detailed records. > > Here is the code: > > Code: > Private Sub FillHeader(ByRef dsDataSet As DataSet) > Try > txtKey.DataBindings.Add(New Binding("text", dsDataSet , "header.key")) > txtNo.DataBindings.Add(New Binding("text", dsDataSet , "header.no")) > Catch ex As Exception > HandleExceptions(ex) > End Try > End Sub > > Code: > Private Sub FillLines(ByRef dsDataSet As DataSet) > Try > dsDataSet.Tables("lines").Columns("key").ColumnMapping = > MappingType.Hidden > dsDataSet.Tables("lines").Columns("product_id").ColumnName = "Product > Id" > dsDataSet.Tables("lines").Columns("quantity").ColumnName = "Quantity" > dgLines.SetDataBinding(dsDataSet.Tables!lines, "HeaderLines") > Catch ex As Exception > HandleExceptions(ex) > End Try > End Sub > > The sub I use to navigate is (For example I put only the next command): > > Code: > Sub cmdNext() Implements ICommandNext.cmdNext > Try > bdRecordNavigator = BindingContext(dsHeader, "header") > bdRecordNavigator.Position += 1 > Catch ex As Exception > HandleExceptions(ex) > End Try > End Sub > > My problem happens when I navigate between the master records. The textboxes > show the correct values, but there is no change in the datagrid. What do I > miss here, that this sub will handle the datagrid as well? > > Thanks > > > Ken Tucker,
Thanks for your reply The tips you supplyed heled me a lot. All I had to do was to add a line before the catch statement that solved the whole problem: dgItems.SetDataBinding(dsPOHeader, "purchase_order_header.POHeaderLines") Thanks again Ohad Show quoteHide quote "Ken Tucker [MVP]" <KenTucker***@discussions.microsoft.com> wrote in message news:B5C41781-8D8F-487C-9F7C-D9B3817FD490@microsoft.com... > Hi, > > You need to use datagrid.setdatabinding to get the child grid to > only display the filtered records. > > http://www.vb-tips.com/default.aspx?ID=a1a84750-08df-49b4-8657-7bc3068aca2c > > http://www.vb-tips.com/default.aspx?ID=3eafa9ea-a906-45ff-aece-e8335682ad3a > > Ken > ----------------- > > "no" wrote: > >> Hi all, >> >> I have a dataset that contain 2 tables and a relationship between them >> (master detail). >> I bind this dataset to a form that include some textboxes that bind to >> the >> parent record, and a datagrid that is binded to the detailed records. >> >> Here is the code: >> >> Code: >> Private Sub FillHeader(ByRef dsDataSet As DataSet) >> Try >> txtKey.DataBindings.Add(New Binding("text", dsDataSet , >> "header.key")) >> txtNo.DataBindings.Add(New Binding("text", dsDataSet , "header.no")) >> Catch ex As Exception >> HandleExceptions(ex) >> End Try >> End Sub >> >> Code: >> Private Sub FillLines(ByRef dsDataSet As DataSet) >> Try >> dsDataSet.Tables("lines").Columns("key").ColumnMapping = >> MappingType.Hidden >> dsDataSet.Tables("lines").Columns("product_id").ColumnName = "Product >> Id" >> dsDataSet.Tables("lines").Columns("quantity").ColumnName = "Quantity" >> dgLines.SetDataBinding(dsDataSet.Tables!lines, "HeaderLines") >> Catch ex As Exception >> HandleExceptions(ex) >> End Try >> End Sub >> >> The sub I use to navigate is (For example I put only the next command): >> >> Code: >> Sub cmdNext() Implements ICommandNext.cmdNext >> Try >> bdRecordNavigator = BindingContext(dsHeader, "header") >> bdRecordNavigator.Position += 1 >> Catch ex As Exception >> HandleExceptions(ex) >> End Try >> End Sub >> >> My problem happens when I navigate between the master records. The >> textboxes >> show the correct values, but there is no change in the datagrid. What do >> I >> miss here, that this sub will handle the datagrid as well? >> >> Thanks >> >> >> Ken Tucker,
Thanks for your reply The tips you supplyed heled me a lot. All I had to do was to add a line before the catch statement that solved the whole problem: dgLines.SetDataBinding(dsDataSet, "header.HeaderLines") Thanks again Ohad Show quoteHide quote "Ken Tucker [MVP]" <KenTucker***@discussions.microsoft.com> wrote in message news:B5C41781-8D8F-487C-9F7C-D9B3817FD490@microsoft.com... > Hi, > > You need to use datagrid.setdatabinding to get the child grid to > only display the filtered records. > > http://www.vb-tips.com/default.aspx?ID=a1a84750-08df-49b4-8657-7bc3068aca2c > > http://www.vb-tips.com/default.aspx?ID=3eafa9ea-a906-45ff-aece-e8335682ad3a > > Ken > ----------------- > > "no" wrote: > >> Hi all, >> >> I have a dataset that contain 2 tables and a relationship between them >> (master detail). >> I bind this dataset to a form that include some textboxes that bind to >> the >> parent record, and a datagrid that is binded to the detailed records. >> >> Here is the code: >> >> Code: >> Private Sub FillHeader(ByRef dsDataSet As DataSet) >> Try >> txtKey.DataBindings.Add(New Binding("text", dsDataSet , >> "header.key")) >> txtNo.DataBindings.Add(New Binding("text", dsDataSet , "header.no")) >> Catch ex As Exception >> HandleExceptions(ex) >> End Try >> End Sub >> >> Code: >> Private Sub FillLines(ByRef dsDataSet As DataSet) >> Try >> dsDataSet.Tables("lines").Columns("key").ColumnMapping = >> MappingType.Hidden >> dsDataSet.Tables("lines").Columns("product_id").ColumnName = "Product >> Id" >> dsDataSet.Tables("lines").Columns("quantity").ColumnName = "Quantity" >> dgLines.SetDataBinding(dsDataSet.Tables!lines, "HeaderLines") >> Catch ex As Exception >> HandleExceptions(ex) >> End Try >> End Sub >> >> The sub I use to navigate is (For example I put only the next command): >> >> Code: >> Sub cmdNext() Implements ICommandNext.cmdNext >> Try >> bdRecordNavigator = BindingContext(dsHeader, "header") >> bdRecordNavigator.Position += 1 >> Catch ex As Exception >> HandleExceptions(ex) >> End Try >> End Sub >> >> My problem happens when I navigate between the master records. The >> textboxes >> show the correct values, but there is no change in the datagrid. What do >> I >> miss here, that this sub will handle the datagrid as well? >> >> Thanks >> >> >>
Getting Exception on Command Line Args, but works within IDE debug
Multi-line comments Communication between forms VS2005 - Passing NumericUpDown into a class method? Legacy Connection Object - I need a new one Execute something stored in a variable Editing Multiple DataGridViews security issues with an upgraded VB6 program IE Privacy - DNS Problem - ASP.NET DX9 SDK (Feb 2006) / .NET 2.0 |
|||||||||||||||||||||||