I am loading my Dropdownlist (CmbRec) using code A, buyt when I use code B and try to use ReceiverID of the first row displayed, with the following code.
I receive the following error:
But I am able to retrieve DonorID from Dropdownlist1, can’t figure out why it’s working for Dropdownlist1 and not for CmbRec. Can you please help me figure out why I can’t extract the ReceiverID value from CmbRec.
Dim xdDonor As New Xml.XmlDocument
Dim xdLink As New Xml.XmlDocument
Dim xdReceiver As New Xml.XmlDocument
' load all of the XML documents
' This outer loop will iterate over the Link file where the ReceiverID node is equal to our search criteria
For Each xnLink As Xml.XmlNode In xdLink.SelectNodes("/Root/Link[ReceiverID='" & C1Country.SelectedItem.Value & "']")
' Extract the ReceiverID and DonorID values from the current node
Dim ReceiverID As String
Dim DonorID As String
ReceiverID = xnLink.SelectSingleNode("ReceiverID").InnerText
DonorID = xnLink.SelectSingleNode("DonorID").InnerText
' Perform another similar search based upon the Donor XML file
For Each xnDonor As Xml.XmlNode In xdDonor.SelectNodes("/Root/Donor[DonorID='" & DonorID & "']")
' Extract the DonorID and Name values from the current node
Dim DonorID2 As String
Dim Name As String
DonorID2 = xnDonor.SelectSingleNode("DonorID").InnerText
Name = xnDonor.SelectSingleNode("Name").InnerText
' Perform yet another practically identical search on the Receiver XML file
For Each xnReceiver As Xml.XmlNode In xdReceiver.SelectNodes("/Root/Receiver[ReceiverID='" & ReceiverID & "']")
' Extract the ReceiverID and Name values from the current node
Dim ReceiverID2 As String
Dim Name As String
ReceiverID2 = xnReceiver.SelectSingleNode("ReceiverID").InnerText
Name = xnReceiver.SelectSingleNode("Name").InnerText
CmbRec.DataSource = dtReceiver
CmbRec.DataTextField = "Name"
CmbRec.DataValueField = "ReceiverID"
DropDownList1.DataSource = dtDonor
DropDownList1.DataTextField = "Name"
DropDownList1.DataValueField = "DonorID"
Dim an As String
an = MsgBox("Are you sure you want to Delete this record?", MsgBoxStyle.YesNo, "Warning before Attempting to Save Data")
If an = MsgBoxResult.Yes Then
Dim xml As String = LinkStream.InnerXml
Dim newline As String = Environment.NewLine
Dim replacement As String = "<Link><ReceiverID>" & CmbRec.SelectedItem.Value & "</ReceiverID><DonorID>" & DropDownList1.SelectedItem.Value & "</DonorID></Link>"
LinkStream.InnerXml = xml.Replace(replacement, "")
Dim cnt As Integer = LinkStream.SelectNodes("Root/Link").Count
MsgBox("Record was deleted")
If an = MsgBoxResult.No Then
MsgBox("Record was not deleted")