472,784 Members | 1,289 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,784 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 2568
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...
0
by: Rina0 | last post by:
Cybersecurity engineering is a specialized field that focuses on the design, development, and implementation of systems, processes, and technologies that protect against cyber threats and...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: lllomh | last post by:
How does React native implement an English player?
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth

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.