Help in my VB Code .. to Delete


S

Sean

hi,

I have been trying to solve this problem since morning, and haven't really come up with a solution. it is frustrating. please help.

i have a datagrid and got a delete column

<asp:datagrid id="dgdocument" runat="server" AutoGenerateColumns="False" EnableViewState="True" OnDeleteCommand="DeleteCommand">
<Columns>
<asp:ButtonColumn Text="Delete" CommandName="Delete"></asp:ButtonColumn>
<asp:BoundColumn DataField="Param1" HeaderText="Param1"></asp:BoundColumn>
<asp:BoundColumn DataField="Param2" HeaderText="Param2"></asp:BoundColumn>
<asp:BoundColumn DataField="Param3" HeaderText="Param3"></asp:BoundColumn>
</Columns>
</asp:datagrid>


and the VB code is

Sub DeleteCommand(ByVal Sender As Object, ByVal E As DataGridCommandEventArgs)
Dim deletekey = dgdocument.DataKeys(CInt(E.Item.ItemIndex))
Response.Write(deletekey)

'load the XML
Dim doc As New XmlDocument()
doc.Load("c:\Inetpub\wwwroot\Cashier\cashier.xml")
Dim onode As XmlElement = doc.SelectSingleNode("cashier/tag[@section='workinformation-" & lbunique.Text & "' and @param1='& deletekey & ' ]")

'not to sure whether this is right
Dim oldNode As XmlNode = doc.RemoveChild("cashier/tag[@section='workinformation-" & lbunique.Text & "' and @param1='& deletekey & ' ]")

' ---------------- this is not right : deleting the node
onode.RemoveChild(oldNode)

' save the xml
doc.Save("c:\Inetpub\wwwroot\Cashier\cashier.xml")

dgdocument.EditItemIndex = -1
viewxmldtn()
End Sub

and the XML file is

<cashier>
<tag section="work-14" param1="1" param2="345" param3="7/9/2003 08:00 AM" />
<tag section="work-14" param1="2" param2="345" param3="7/9/2003 08:00 AM" />
<tag section="work-14" param1="3" param2="345" param3="7/9/2003 08:00 AM" />
</cashier>
Param1 is a unique field.


What should the right syntax be to remove the node from the XML file.

Any help is appreciated.

Thank You
 
Ad

Advertisements


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

VB code help 3
Help converting C# code to VB 4
this C# code in VB? 7
VB code formatter 3
VB Coding Standards... 1
VB Coding Standards 3
Equivalent code in VB for a C# code 2
Great VB GUI Code 1

Top