Solved

How to delete rows in xml files based on rows selected from a Grid?

Posted on 2011-02-24
2
461 Views
Last Modified: 2012-05-11
Hello,

How do I delete records in my Link.xml file when I delete a record from the grid control. For example if I select a row with Fuze_ID = 5, I would like to loop through my Link.xml file and delete all the records with Fuze_ID = 5.

I'm using the code code below, but I'm receiving the following error:
"Index 5 is either negative or above rows count"

On line: DV.Item(X).Delete()

Any ideas what's wrong with the code.

Thanks,

Victor

Dim dr As DataRow = dt.NewRow()    
dr("Link_ID") = linkID    
dr("Fuze_ID") = FuzeID    
dt.Rows.Add(dr)    
Next    
'Delete Selecete Record    
Dim X As Integer    
Dim DV As New DataView(dt, "Fuze_ID like " & "'" & C1TrueDBGrid.Columns(0).Value & "'" & "", Nothing, DataViewRowState.CurrentRows)    
 
For X = 0 To DV.Count - 1    
DV.Item(X).Delete()    
Next    
Dim DV1 As New DataView(dt, "", Nothing, DataViewRowState.CurrentRows)    
Dim FilteredDT As DataTable    
FilteredDT = DV1.ToTable    
'put data back to xml file    
FilteredDT.TableName = "Row"    
FilteredDT.WriteXml(Application.StartupPath + "\Link.xml")
0
Comment
Question by:vcharles
2 Comments
 
LVL 11

Accepted Solution

by:
srikanthreddyn143 earned 500 total points
Comment Utility
You are supposed to look for fuze id 5 but your code is deleting 5 th row
0
 

Author Closing Comment

by:vcharles
Comment Utility
Thanks.
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
Confronted with some SQL you don't know can be a daunting task. It can be even more daunting if that SQL carries some of the old secret codes used in the Ye Olde query syntax, such as: (+)     as used in Oracle;     *=     =*    as used in Sybase …
This tutorial demonstrates a quick way of adding group price to multiple Magento products.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now