Cannot remove a detached row from a DataTable

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Hamed

    #1

    Cannot remove a detached row from a DataTable

    Hello

    I have a DataTable bound to a DataGrid. During working with the grid, some
    detached rows are created internally by the grid. I want to remove the
    detached rows from the DataTable but calling myDataTable.Row s.Remove(myRow)
    have no effect on it. What am I missing?

    I tried to add the row and then delete and then call AcceptChanges but no
    success.

    Please help

    Thanks in advance.
    Hamed


  • =?Utf-8?B?UmljaA==?=

    #2
    RE: Cannot remove a detached row from a DataTable

    Maybe this would work:

    For Each dr As DataRow in myDataTable.Row s
    If someCondition.E quals(True) Then
    myDataTable.Row s.Remove(dr)
    End If
    Next

    This will specify what rows(s) to remove. Another way is this:

    Dim dr As DataRow = myDataTable.Row s(5)
    myDataTable.Row s.Remove(dr)

    HTH
    Rich

    "Hamed" wrote:
    Hello
    >
    I have a DataTable bound to a DataGrid. During working with the grid, some
    detached rows are created internally by the grid. I want to remove the
    detached rows from the DataTable but calling myDataTable.Row s.Remove(myRow)
    have no effect on it. What am I missing?
    >
    I tried to add the row and then delete and then call AcceptChanges but no
    success.
    >
    Please help
    >
    Thanks in advance.
    Hamed
    >
    >
    >

    Comment

    • Hamed

      #3
      Re: Cannot remove a detached row from a DataTable

      I tried it. There is no effect of the count of rows and also no exception is
      thrown. it seems Remove method just ignores the detached row.

      Please help.

      Hamed

      "Rich" <Rich@discussio ns.microsoft.co mwrote in message
      news:72BA3DBF-5A1D-438D-9A69-DDA47E8E0E16@mi crosoft.com...
      Maybe this would work:
      >
      For Each dr As DataRow in myDataTable.Row s
      If someCondition.E quals(True) Then
      myDataTable.Row s.Remove(dr)
      End If
      Next
      >
      This will specify what rows(s) to remove. Another way is this:
      >
      Dim dr As DataRow = myDataTable.Row s(5)
      myDataTable.Row s.Remove(dr)
      >
      HTH
      Rich
      >
      "Hamed" wrote:
      >
      >Hello
      >>
      >I have a DataTable bound to a DataGrid. During working with the grid,
      >some
      >detached rows are created internally by the grid. I want to remove the
      >detached rows from the DataTable but calling
      >myDataTable.Ro ws.Remove(myRow )
      >have no effect on it. What am I missing?
      >>
      >I tried to add the row and then delete and then call AcceptChanges but no
      >success.
      >>
      >Please help
      >>
      >Thanks in advance.
      >Hamed
      >>
      >>
      >>

      Comment

      Working...