PC Review


Reply
Thread Tools Rate Thread

Cannot remove a detached row from a DataTable

 
 
Hamed
Guest
Posts: n/a
 
      13th Feb 2007
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


 
Reply With Quote
 
 
 
 
=?Utf-8?B?UmljaA==?=
Guest
Posts: n/a
 
      13th Feb 2007
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
>
>
>

 
Reply With Quote
 
Hamed
Guest
Posts: n/a
 
      14th Feb 2007
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" <(E-Mail Removed)> wrote in message
news:72BA3DBF-5A1D-438D-9A69-(E-Mail Removed)...
> 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
>>
>>
>>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Cannot remove a detached row from a DataTable Hamed Microsoft Dot NET 2 14th Feb 2007 08:59 AM
Cannot remove a detached row from a DataTable Hamed Microsoft C# .NET 3 14th Feb 2007 08:59 AM
Cannot remove a detached row from a DataTable Hamed Microsoft ADO .NET 3 14th Feb 2007 08:59 AM
detached rows in DataTable jurson Microsoft C# .NET 5 7th Feb 2005 12:18 PM
Detached rows in a datatable Peter Borremans Microsoft ADO .NET 9 19th Mar 2004 01:52 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:25 AM.