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