For Each drdepts In depts_changes.Table.RowsWhat you are doing is pointing to the table that the dataview is based on, which is the unfiltered datasource. I have done this before, so that is why I know... :-)
For Each drdepts In depts_changes>Hi all!
>Private Sub Del_btn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Del_btn.Click > Dim error_msg As String > Dim depts_changes As New DataView > Dim drdepts As DataRow > Dim I As Integer > Dim Y As Integer > error_msg = "Some of the record selected is been using in other" > error_msg = error_msg + vbCrLf + "databases:" > depts_changes.Table = Me.Depts_LookupDataSet.Tables(0) > depts_changes.RowFilter = "Lsele = True" > For Each drdepts In depts_changes.Table.Rows > Try > Me.Dept_Delete_SQLCMD.Parameters("@Dept_Pk").Value = drdepts("DepartmentsPK") > 'Me.Dept_Delete_SQLCMD.Parameters("@Return_Value").Value = 0 > Me.Uan_SqlConnection.Open() > Me.Dept_Delete_SQLCMD.ExecuteNonQuery() > Me.Uan_SqlConnection.Close() > If Me.Dept_Delete_SQLCMD.Parameters("@Return_Value").Value = True Then > I = I + 1 > error_msg = error_msg + vbCrLf + drdepts("DepartmentAbbreviation") + " " + drdepts("DepartmentName") > Else > Y = Y + 1 > End If > Catch ex As Exception > MessageBox.Show(ex.ToString) > Me.Uan_SqlConnection.Close() > End Try > Next > If I > 0 Then > MessageBox.Show(error_msg) > End If > If Y > 0 Then > Me.MSG_TXT.Text = CType(Y, String) + " record(s) has been deleted" > End If > Me.Fill_Parent_Grid() > > End Sub >