473,405 Members | 2,167 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

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
2 1652
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 13 '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

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

45
by: Jamie Burns | last post by:
Hello, I realise that I just dont get this, but I cannot see the need for auto_ptr. As far as I have read, it means that if you create an object using an auto_ptr, instead of a raw pointer, then...
1
by: frank | last post by:
I have two DataTables, A and B. Both have the primary key "CID". How do I remove all entries in Table A from Table B (with the same PK)?
0
by: acharyaks | last post by:
Hi life saver, I am using excel component for the development. The purpose is to connect to excel through the odbc connection string. Then through the connection extract data into a dataset and...
5
by: jurson | last post by:
Hello, I remove row from DataTable. It works ok, the row is removed from collection. It should be marked as 'detached'. Am I right? Then I try to retrieve 'detached' rows using the code shown...
7
by: Wayne Brantley | last post by:
I have found what appears to be an error in streaming with Datasets. It causes an error of 'Cannot find relation 0' when recreating the dataset from a stream. Here is how you reproduce it. ...
7
by: Juan Romero | last post by:
Hey guys, please HELP I am going nuts with the datagrid control. I cannot get the damn control to refresh. I am using soap to get information from a web service. I have an XML writer output...
0
by: Ryan Liu | last post by:
Hi, I notice a DataRow in Detached when it is just created by dataTable.NewRow(), and when added to a dataTalbe's row collection, then removed from that collection. For the first situation, I...
1
by: Ryan Liu | last post by:
Hi, Is that safe to say a Detached DataRow neve in a DataTable's Rows collectoin? But in my log file, I do see a Detached row: foreach(DataRow dr in this.currentQuotaUserDt.Rows) {
3
by: Hamed | last post by:
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...
8
by: jehugaleahsa | last post by:
Hello: We wrote an entire application where we add our DataRows to our DataTables immediately. However, we have to shut off our constraints to do this. We would like to use detached DataRows to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.