Featured

Databound DropDowlist DataSet XML

Well we wanted to bind a dropdownlist to an XML file on the HDD of the server. This could be done a couple of ways, but because we specifically want to use a DataSet later in learning we will use that object for this purpose.

First create the DataSet


Dim ds as new System.data.Dataset

Then load the Ds with XML. We use mappath to map a relative path to a physical path on the server.

ds.loadxml(mappath(“../database/myxml.xml”))

Then assuming we already have dragged a control onto our form named dropdownlist1 we can bind the control to the ds.

Dropdownlist1.datasource = ds
dropdownlist1.databind()

Alternatively we can specify which fileds we want to use for the text and value properties:

dropdownlist1.datatextfield = "name"
dropdownlist1.datavaluefield = "ID"
Dropdownlist1.datasource = ds
dropdownlist1.databind()

remember that name and id are just columns in my xml file.

For a simple video of this process check out:
http://www.jasncab.com/devry/cis410


Trackback  •  Posted by Jason in Uncategorized category

 

Please leave a reply...



You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>