-
May 2nd, 2012, 06:17 AM
#1
Adding row to dataview
Hi, i am trying to add several rows to a dataview before bindng it to the datagridview. I have tried several variations of the below code but only the last row will actuall load into the grid. Probably doing something stupid. Any help will be appreciated.
My code is:
dvInspectDetail.AllowNew = True
Dim newRow1 As DataRowView = dvInspectDetail.AddNew
newRow1("IDetail") = mDetailNo.ToString
newRow1("IDDescr") = "Kiddi count = " & mKiddi
newRow1("IDRate1") = False
newRow1("IDRate2") = False
newRow1("IDRate3") = False
'newRow1.EndEdit()
Dim newRow2 As DataRowView = dvInspectDetail.AddNew
newRow2("IDetail") = mDetailNo.ToString
newRow2("IDDescr") = "Midi count = " & mMidi
newRow2("IDRate1") = False
newRow2("IDRate2") = False
newRow2("IDRate3") = False
'newRow2.EndEdit()
Dim newRow3 As DataRowView = dvInspectDetail.AddNew
newRow3("IDetail") = mDetailNo.ToString
newRow3("IDDescr") = "Maxi count = " & mMaxi
newRow3("IDRate1") = False
newRow3("IDRate2") = False
newRow3("IDRate3") = False
'newRow3.EndEdit()
Dim newRow4 As DataRowView = dvInspectDetail.AddNew
newRow4("IDetail") = mDetailNo.ToString
newRow4("IDDescr") = "Jumbo count = " & mJumbo
newRow4("IDRate1") = False
newRow4("IDRate2") = False
newRow4("IDRate3") = False
'newRow4.EndEdit()
Dim newRow5 As DataRowView = dvInspectDetail.AddNew
newRow5("IDetail") = mDetailNo.ToString
newRow5("IDDescr") = mComment
newRow5("IDRate1") = False
newRow5("IDRate2") = False
newRow5("IDRate3") = False
'newRow5.EndEdit()
MsgBox(dvInspectDetail.Count)
dgvInspectDetail.DataSource = dvInspectDetail
Many thanks in advance.
Alwyn
-
May 2nd, 2012, 10:22 AM
#2
Re: Adding row to dataview
Several hours later and i still cant figure this one out. What i have found is that only one row will add to the dataview (irrespective if you dim the rows the same or different variables) and only the last parameter sent will be updated in the row. I have tried it in a for next loop, but makes no difference. There is also no .update or .acceptchanges to force the row update after each new rowadd. Interesting is that if i uncomment the .endedit, then no rows are added to the dataview.
I am hoping that my learned colleaguesout there can figure this one out.
Tx
Alwyn
-
May 2nd, 2012, 02:27 PM
#3
Re: Adding row to dataview
Need to UPDATE each row, or SAVE it each time... Depends how the table is bound.
Why not just enter it into an unbound form?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|