Hi,
I have the following code that I would like to get working, but for some reason, it keeps giving me the wrong output, and I wonder if anyone on the list might be able to help me fix it.
Here is the code,
Sub submit(ByVal sender As Object, ByVal e As EventArgs)
songNodesOut.Text = ""
Dim file As String = Context.Server.MapPath("music.xml")
Dim document As XmlDocument = New XmlDocument()
document.Load(file)
Dim songList As XmlNodeList
songList = document.SelectNodes("/music_songs/song[category='Rock']")
Dim count As Integer = songList.Count
Dim page AS Decimal = songList.Count/10
Dim IntegerPart As Integer= Int(page)
Dim DecimalPart As Decimal = page - IntegerPart
Dim page_no As Integer
Dim item_number_first As Integer
Dim item_number_last As Integer
Dim song As XmlNode
Dim d As Integer
if(DecimalPart >0) Then
IntegerPart+=1
page_no = 1
if page_no = IntegerPart
item_number_first = (page_no-1)*10 + 1
item_number_last = count
For Each song In songList
For d=item_number_first to item_number_last
songNodesOut.Text &= "<br /><b>ID:</b> " & d & "<br />"
Dim title As XmlNode = song.FirstChild
songNodesOut.Text &= "<b>Title:</b> " & title.InnerText & "<br/>"
Next d
Next
end If
End If
mess.Text += "<p>You selected <b>" & drop1.SelectedItem.Text & " " & count & " items</b>. That is " & IntegerPart & " pages</p>"
mess.Text += "<br />Items for page " & page_no & " is: " & item_number_first & " to " & item_number_last & "<br />"
<%-- page_no +=1 --%>
End Sub
What this code is supposed to do, I am trying to achieve, is to change it so that I could use pagination with it. However, the problem with this code right now is that the ID's are generated, but iterates over the songs with duplicate entries, like:
1 Hello
2 Hello
1 Cool
2 Cool
Is it possible if I could have code above only get this to print out?
1 Hello
2 Cool
Thanks for your help. Anything is appreciated.