|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Cannot remove a detached row from a DataTableHello
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 Are you getting an error? you ... jeez why is this posted to so many
newsgroups? -- Show quoteRegards, 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.com> wrote in message news:eRVuwM2THHA.4276@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 > Because the problem is related to both binding and ado.net
Show quote "Alvin Bruney [MVP]" <some guy without an email address> wrote in message news:OJmV8x8THHA.3592@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.com> wrote in message > news:eRVuwM2THHA.4276@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 >> > > 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 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 Show quote "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 > > > 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 Show quote "Rich" <R***@discussions.microsoft.com> wrote in message news:72BA3DBF-5A1D-438D-9A69-DDA47E8E0E16@microsoft.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 >> >> >> 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 Show quote "Rich" <R***@discussions.microsoft.com> wrote in message news:72BA3DBF-5A1D-438D-9A69-DDA47E8E0E16@microsoft.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 >> >> >> 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 Show quote "Rich" <R***@discussions.microsoft.com> wrote in message news:72BA3DBF-5A1D-438D-9A69-DDA47E8E0E16@microsoft.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 >> >> >> |
|||||||||||||||||||||||