ourman
Jun 13th, 2002, 01:53 PM
I solved the issue, in case u need the answer here it's:
Select Case strRowState
Case "Added"
'
'.... Add new record, etc...
'
Case "Edited"
' Getting ID of the selected record to be updated
myListView = Me.ListView1.SelectedItems(0)
lngID = CLng(myListView.SubItems(1).Text.ToString)
' Having a Datarow var pointing to the record to be updated
myDataRow = Me.DataSet1.Tables("tblCheckListItems").Rows.Find(lngID)
' Put the DataRow var into edit mode
myDataRow.BeginEdit()
myDataRow("CheckListItem") = Me.txtItem.Text
myDataRow.EndEdit()
' Actually update the record to the database by updating the
' DataAdapter Object
Try
OleDbDataAdapter1.Update(Me.DataSet1, "tblCheckListItems")
Catch x As Exception
' Error during Update, add code to locate error
MsgBox(x.ToString)
End Try
End Select
' Fill the listview, if it was Edited then do not select the first row
FillListView(Me.ListView1, lngID = 0)
' If listview was edited the return to selected row
If lngID > 0 Then
For intLoop = 0 To Me.ListView1.Items.Count
myListView = Me.ListView1.Items(intLoop)
If CLng(myListView.SubItems(1).Text.ToString) = lngID Then
Me.ListView1.Items(intLoop).Selected = True
Me.ListView1.Items(intLoop).EnsureVisible()
intLoop = Me.ListView1.Items.Count
End If
Next
End If
Select Case strRowState
Case "Added"
'
'.... Add new record, etc...
'
Case "Edited"
' Getting ID of the selected record to be updated
myListView = Me.ListView1.SelectedItems(0)
lngID = CLng(myListView.SubItems(1).Text.ToString)
' Having a Datarow var pointing to the record to be updated
myDataRow = Me.DataSet1.Tables("tblCheckListItems").Rows.Find(lngID)
' Put the DataRow var into edit mode
myDataRow.BeginEdit()
myDataRow("CheckListItem") = Me.txtItem.Text
myDataRow.EndEdit()
' Actually update the record to the database by updating the
' DataAdapter Object
Try
OleDbDataAdapter1.Update(Me.DataSet1, "tblCheckListItems")
Catch x As Exception
' Error during Update, add code to locate error
MsgBox(x.ToString)
End Try
End Select
' Fill the listview, if it was Edited then do not select the first row
FillListView(Me.ListView1, lngID = 0)
' If listview was edited the return to selected row
If lngID > 0 Then
For intLoop = 0 To Me.ListView1.Items.Count
myListView = Me.ListView1.Items(intLoop)
If CLng(myListView.SubItems(1).Text.ToString) = lngID Then
Me.ListView1.Items(intLoop).Selected = True
Me.ListView1.Items(intLoop).EnsureVisible()
intLoop = Me.ListView1.Items.Count
End If
Next
End If