Getting error when showing data in list view, please help me.....
Error : Cannot add or insert the item '10-07-2018' in more than one place. You
must first remove it from its current location or clone it.
Parameter name: item
I use Vb.net 2010 visual basic
sql server 2008 r2
stored procedure
one listview
I want this type of structure (example)
id date item_name qty. amount
1 1/1/2019 a 2 10
B 1 12
x 14 100
zz 4 52
2 4/1/2019 M 5 80
N 4 50
But when I showing to the data 1st item show on list view then getting the error.
It is possible please help me
What I have tried:
With obj_S_J_RPT
ListView1.Items.Clear()
.Sdate = txtdtf.Text
.EDate = txtdtt.Text
dt1 = .GetStockJournalRPT()
For i As Integer = 0 To dt1.Rows.Count - 1
Dim dr As DataRow = dt1.Rows(i)
Dim listitem As New ListViewItem(dr("SJDate").ToString())
listitem.SubItems.Add(dr("itemnmsou").ToString())
listitem.SubItems.Add(dr("SJqty").ToString())
listitem.SubItems.Add(dr("SJPCS").ToString())
listitem.SubItems.Add(dr("SJRate").ToString())
listitem.SubItems.Add(dr("SJamt").ToString())
listitem.SubItems.Add(dr("SJleft").ToString())
listitem.SubItems.Add(dr("nrr").ToString())
listitem.SubItems.Add(dr("SJID").ToString())
Try
With obj_S_J_RPT
'ListView2.Items.Clear()
.SJID = dr.Item(0) 'ListView1.Items(0).SubItems(8).Text
dt2 = .GetStockJournalDetails() 'change
For i1 As Integer = 0 To dt2.Rows.Count - 1
Dim dr1 As DataRow = dt2.Rows(i1)
ListViewItem(dr1("itemnmDES").ToString())
listitem.SubItems.Add(dr1("itemnmDES").ToString())
listitem.SubItems.Add(dr1("SJdqty").ToString())
listitem.SubItems.Add(dr1("SJdPCS").ToString())
listitem.SubItems.Add(dr1("SJdRate").ToString())
listitem.SubItems.Add(dr1("SJdamt").ToString())
listitem.SubItems.Add(dr1("SJDstock").ToString())
listitem.SubItems.Add(dr1("SJid").ToString())
ListView1.Items.Add(listitem)
Next i1
End With
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Critical)
End Try
ListView1.Items.Add(listitem)
Next
End With