Click here to Skip to main content
15,887,746 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Everyone ..

I have a form with 3 datagridview. Each of these grids has separate bindingsource as datasource and this bindingsource has been assigned datatable as datasource on Form_Load:

VB
bsDimensions.DataSource = dtDimension
dgvDimension.DataSource = bsDimensions.DataSource

bsEntityValue.DataSource = dtEntity
dgvEntityValue.DataSource = bsEntityValue

bsCurrency.DataSource = dtCurrencies
dgvCurrency.DataSource = bsCurrency


When user clicks on a row of dgvDimension it filters bindingSource of other 2 grids:

VB
bsEntityValue.Filter = "DimensionCode = '" & dgvDimension.Rows(e.RowIndex).Cells(ColDimensionCode.Index).Value & "'"
If dgvEntityValue.CurrentRow IsNot Nothing Then
    bsCurrency.Filter = "CurrencyDimensionCode = '" & dgvDimension.Rows(e.RowIndex).Cells(ColDimensionCode.Index).Value.ToString.Trim & "' And CurrencyEntityValue = '" & dgvEntityValue.CurrentRow.Cells(ColEntityValue.Index).Value.ToString.Trim & "'"
End If


Please note that every grid has a checkbox column (RowSelected) to select required rows. Afterwards when user clicks Save button then following steps perform:

VB
dgvDimension.Update()
dgvEntityValue.Update()
dgvCurrency.Update()
dgvDimension.CommitEdit(DataGridViewDataErrorContexts.Commit)
dgvEntityValue.CommitEdit(DataGridViewDataErrorContexts.Commit)
dgvCurrency.CommitEdit(DataGridViewDataErrorContexts.Commit)
dgvDimension.EndEdit()
dgvEntityValue.EndEdit()
dgvCurrency.EndEdit()
dgvDimension.Refresh()
dgvEntityValue.Refresh()
dgvCurrency.Refresh()

Dim dtEntities As Data.DataTable = bsEntityValue.DataSource
Dim dtCurrencies As Data.DataTable = bsCurrency.DataSource

Dim ResultEntities As Data.DataRow()
Dim ResultCurrency As Data.DataRow()

ResultEntities = dtEntities.Select("RowSelected=1")

Now here is the issue:
if user clicks just one row in "dgvDimension" and makes some changes in "dgvEntityValue" and clicks save, then this "dtEntities.Select" only filters rows which are related to this particular row of "dgvDimension". Same way if user clicks lets say 3 rows in "dgvDimension" and makes some changes, then this "dtEntities.Select" filters rows related to these 3 rows.

Please advice as what could be the issue? why isn't it filtering all checked rows in dtEntities. Please note that dtEntities contains all rows of all dimensions so it should select all rows which are checked.

Thanks and Regards

Zee Shan
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900