Bind two XML datasources to the same repeater

hm9

New member
Joined
Dec 26, 2019
Messages
1
Programming Experience
Beginner
I am trying to bind 2 datasources from xml data to the same repeater. the second one always overwrite the first one. The binding works without any errors but it doesnt do it for both datasources, only the second one. Below is snippet of the code that does the binding. Is there a way to join the datasources and just do the binding once?. i cant use Arrays as the datasource type is IEnumerable. The repeater section doing the binding are on line 21,22 and 45,46, so the second one overwrites the first one. Need a workaround to make it bind both of the them and no overwrite. Thanks

---Code that gets the data from the XML1 API....
rpMyRepeater.Datasource = datasource1
Code that retrieve elements from xml and bind them to repeater:
New XmlDocument()
dim docx = ("http://api.url.com/1.0/products.xml;q='%"&Request.QueryString("id")&"%';tdCategoryId=168;%20category=travel;fid=22212;limit=40;orderBy=priceAsc;priceHistory=true;pretty=true?token=xxxxxxxxxxxxxxxxxxx")

doc.Load(docx)

Dim nsManager As New XmlNamespaceManager(doc.NameTable)
nsManager.AddNamespace("ns1", "urn:com:tradedoubler:pf:model:xml:output")
nsManager.AddNamespace("ns2", "urn:com:tradedoubler:pf:model:xml:common")
Dim nodes As XmlNodeList = doc.SelectNodes("//ns1:products/ns1:product", nsManager)
Dim dataSource As  IEnumerable

dataSource = From node As XmlNode in nodes
Select Name = node.SelectSingleNode("ns2:name", nsManager).InnerText, _
Description = node.SelectSingleNode("ns2:description", nsManager).InnerText, _
Image = node.SelectSingleNode("ns2:productImage", nsManager).InnerText, _
Price = node.SelectSingleNode("ns1:offers/ns1:offer/ns1:priceHistory/ns2:price", nsManager).InnerText, _
ProductUrl = node.SelectSingleNode("ns1:offers/ns1:offer/ns2:productUrl", nsManager).InnerText, _
ProgramName = node.SelectSingleNode("ns1:offers/ns1:offer/ns2:programName", nsManager).InnerText, _
Logo = node.SelectSingleNode("ns1:offers/ns1:offer/ns2:programLogo", nsManager).InnerText

rpMyRepeater.Datasource = datasource
rpMyRepeater.Databind()



Dim doc1 As New XmlDocument()
dim docy = ("http://api.url.com/1.0/products.xml;q='%"&Request.QueryString("id")&"%';tdCategoryId=168;%20category=travel;fid=14519;limit=40;orderBy=priceAsc;priceHistory=true;pretty=true?token=”vvvvvvvvvvvvvvvvvvvvvvvvvvv")
doc1.Load(docy)

Dim nsManager1 As New XmlNamespaceManager(doc1.NameTable)
nsManager1.AddNamespace("ns1", "urn:com:tradedoubler:pf:model:xml:output")
nsManager1.AddNamespace("ns2", "urn:com:tradedoubler:pf:model:xml:common")
Dim nodes1 As XmlNodeList = doc1.SelectNodes("//ns1:products/ns1:product", nsManager1)
Dim dataSource1 As IEnumerable

dataSource1 = From node1 As XmlNode in nodes1
Select Name = node1.SelectSingleNode("ns2:name", nsManager1).InnerText, _
Description = node1.SelectSingleNode("ns2:description", nsManager1).InnerText, _
Image = node1.SelectSingleNode("ns2:productImage", nsManager1).InnerText, _
Price = node1.SelectSingleNode("ns1:offers/ns1:offer/ns1:priceHistory/ns2:price", nsManager1).InnerText, _
ProductUrl = node1.SelectSingleNode("ns1:offers/ns1:offer/ns2:productUrl", nsManager1).InnerText, _
ProgramName = node1.SelectSingleNode("ns1:offers/ns1:offer/ns2:programName", nsManager1).InnerText, _
Logo = node1.SelectSingleNode("ns1:offers/ns1:offer/ns2:programLogo", nsManager1).InnerText

rpMyRepeater.Datasource = datasource1
rpMyRepeater.Databind()
 
Top Bottom