Hi Guys,

I have a problem loading data into datagridview control. I have 2 forms with datagridview on both forms. when the user selects a record in form 1, the related records is then displayed in the datagridview in form2. These all works fine but my problem is, when the user selects another record, from the datagridview in form1, the first record already in the datagridview in form2 is replaced by the newly selected record. How can I add another record without removing the any record from the datagridview. Sample code will be highly appreciated.

Cheers

PrivateSub dgvAvailablePhones_DoubleClick(ByVal sender AsObject, ByVal e As System.EventArgs) _
Handles dgvAvailablePhones.DoubleClick
Dim SelectedRowView As Data.DataRowView
Dim SelectedRow As PhonesDataSet.AVAILABLE_PHONESRow
SelectedRowView = CType(AVAILABLEPHONESBindingSource.Current, System.Data.DataRowView)
SelectedRow = CType(SelectedRowView.Row, PhonesDataSet.AVAILABLE_PHONESRow)
'Pass the selected row to the Phone Sales forn
'and display the form
PhoneSales.LoadOrders(SelectedRow.ITEM_ID)
PhoneSales.Show()
Me.Close()
End Sub

FriendSub LoadOrders(ByVal ItemID AsString)
AVAILABLE_PHONESTableAdapter.FillByItemID(PhoneSalesItemsDataSet.AVAILABLE_PHONES, ItemID)
End Sub

Hi,

Keep a Public Array of Selected ID's. In the LoadOrders Fill the DataGrid With all the items in the Array.

Say If ur SQL Query Is:
Select * From OrderDet Where ItemId='aa'

Change It to:
Select * From OrderDet Where ItemId In ('aa','bb','cc','cc')

U can use "Join" function to join array elements

Regards
Veena

commented: Nice +3
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.