fill a dripdwon with XML


/ Published in: VB.NET
Save to your folder(s)



Copy this code and paste it in your HTML
  1. ' must include: Imports System.Web.HttpContext
  2.  
  3. Dim DS As New DataSet()
  4.  
  5. Dim FilePath As String
  6. ''AspEnableParentPaths = True
  7. 'FilePath = Server.MapPath("~/App_Data/tlkpCodeValues.xml")
  8. FilePath = Current.Server.MapPath("App_Data\tlkpCodeValues.xml")
  9.  
  10. DS.ReadXml(FilePath)
  11.  
  12. Dim I As Integer
  13. strddl.Items.Clear()
  14. ' Display the result
  15. For I = 0 To DS.Tables(0).Rows.Count - 1
  16. If DS.Tables(0).Rows(I).Item("CodeType") = strObjParm Then
  17. Dim newListItem As New ListItem
  18. newListItem.Value = DS.Tables(0).Rows(I).Item("Code_Val")
  19. newListItem.Text = DS.Tables(0).Rows(I).Item("ShortDescText")
  20. strddl.Items.Add(newListItem)
  21. End If
  22. Next
  23. strddl.Items.Insert(0, New ListItem("--Choose One--"))

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.