Hi All:
I am trying to delete rows from an UltraDataSource via code, but the underlying DataTable's row doesn't get deleted, because the UltraDataSource1_RowDeleting event never gets fired. Here's my code:
Dim uRow As UltraDataRow
For Each uRow In UltraDataSource1.Rows If uRow("DateOfBirth") Is DBNull.Value AndAlso (uRow("Age") Is DBNull.Value OrElse DirectCast(uRow("Age"), Integer) = 0) Then UltraDataSource1.Rows.Remove(uRow) End If Next
The row gets removed from the UltraDataSource (and hence the UltraGrid, but it NEVER gets deleted from the dtCensus DataTable, because this event is not firing:
Private Sub UltraDataSource1_RowDeleting(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinDataSource.RowDeletingEventArgs) Handles UltraDataSource1.RowDeleting ' RowDeleting is fired when a bound control tries to delete a row. Here ' you delete the associated row from the external data structure. dtCensus.Rows.RemoveAt(e.Row.Index) End Sub
Can anyone help? So far I have come up empty with tech support.
Kevin
Kevin,
Use the overload of the Remove method that takes a boolean parameter specifying whether it should raise the delete events, i.e.
UltraDataSource1.Rows.Remove(uRow, True)
-Matt
Hi Matt:
Great; much thanks. But I am noticing that it's only deleting the first couple of rows. Here's my code:
'Delete the row and raise the Event
End If
Next