473,382 Members | 1,775 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,382 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
3 2610
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 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. ...
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) {
2
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.