470,855 Members | 1,219 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,855 developers. It's quick & easy.

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.Rows.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
Feb 13 '07 #1
3 2496
Are you getting an error? you ... jeez why is this posted to so many
newsgroups?

--
Regards,
Alvin Bruney
------------------------------------------------------
Shameless author plug
Excel Services for .NET is coming...
OWC Black book on Amazon and
www.lulu.com/owc
Professional VSTO 2005 - Wrox/Wiley
"Hamed" <ha***@raymehr.comwrote in message
news:eR**************@TK2MSFTNGP02.phx.gbl...
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.Rows.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

Feb 14 '07 #2
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" <Ri**@discussions.microsoft.comwrote in message
news:72**********************************@microsof t.com...
Maybe this would work:

For Each dr As DataRow in myDataTable.Rows
If someCondition.Equals(True) Then
myDataTable.Rows.Remove(dr)
End If
Next

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

Dim dr As DataRow = myDataTable.Rows(5)
myDataTable.Rows.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.Rows.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

Feb 14 '07 #3
Because the problem is related to both binding and ado.net
"Alvin Bruney [MVP]" <some guy without an email addresswrote in message
news:OJ**************@TK2MSFTNGP06.phx.gbl...
Are you getting an error? you ... jeez why is this posted to so many
newsgroups?

--
Regards,
Alvin Bruney
------------------------------------------------------
Shameless author plug
Excel Services for .NET is coming...
OWC Black book on Amazon and
www.lulu.com/owc
Professional VSTO 2005 - Wrox/Wiley
"Hamed" <ha***@raymehr.comwrote in message
news:eR**************@TK2MSFTNGP02.phx.gbl...
>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.Rows.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


Feb 14 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

45 posts views Thread by Jamie Burns | last post: by
1 post views Thread by frank | last post: by
reply views Thread by acharyaks | last post: by
5 posts views Thread by jurson | last post: by
7 posts views Thread by Wayne Brantley | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.