Hi,
I have an ASP.NET application which shows the list of pays to be processed. I want to use a checkbox to show and change the deleted state but I don't know how. Like in the yahoo messaging where a message can be marked for deletion. Any suggestions
Thanks
Ellie
When an object gets deleted from a list it's not really deleted, it gets pushed into a DeletedList collection. So you could toy with this to make it work. However, I think you'll have some issues given that your use case seems to be that you have a boolean indicator if the object is marked for deletion or not and doing it this way will mean that you'll have to do some gymnastic with both lists.
Alternatively, you could add your own boolean IsMarkedForDeletion property and let this property drive the show sort of speak. Then when the user hits save, loop through the list and _delete_ all rows that are IsMarkedForDeletion = true, then call the save method on you BO.
Hope this helps
I use the checkbox to IncludeLine or not on many of my web pages.
Each of my child BOs has a Boolean property to get/set to see if it is checked.
In the collection class I use code like this when saving:
Protected Friend Overridable Sub Update(ByVal tr As IDbTransaction, ByVal parent As ParentType)
Dim child As ChildType
'need a way to delete existing data in DB. Do this by unchecking them on the screen and testing if they are New.
For i As Integer = List.Count - 1 To 0 Step -1
child = Me.Item(i)
If child.IsNew = False AndAlso child.Includeline = False Then
Me.List.Remove(child)
End If
Next i
For Each child In DeletedList
child.Update(tr, parent)
Next
DeletedList.Clear()
For Each child In List
If child.Includeline = True Then
child.Update(tr, parent)
End If
Next
End Sub
I let the user check/uncheck as many rows as they like.
If they add one or more new rows then we only care about saving therm if they are checked.
Rows that are in the DB and get unchecked need to be deleted from the DB when Saved. That is the purpose of the first block of code. It removes them from the List and puts them in the Deleted list where they get deleted from the DB. Then the remaining checked items get saved to the DB.
Joe
Copyright (c) Marimer LLC