XML Dropdownlist- Custom DataTextField

D

Darrin

I currently have some code that sends some XML to the USPS website and
returns some XML with shipping costs. I am reading the XML and then binding
it to a dropdownlist. However, I would like to bind two of the XML nodes
(MailService & Rate) as the datatextfield. This way the user will be able to
see the mail service type (standard, prority, etc.) and the rate ($8.00,
$6.00, etc.) Currently I am only able to use one of the XML nodes to bind it
to the drop down list. Does anyone have a sample that would allow me to add
more than one data text field?


XML That is being returned:-----------------------------
<?xml version="1.0" ?>

<RateV2Response>

<Package ID="0">

<ZipOrigination>10022</ZipOrigination>

<ZipDestination>20008</ZipDestination>

<Pounds>10</Pounds>

<Ounces>5</Ounces>

<Container>Flat Rate Box</Container>

<Size>REGULAR</Size>

<Zone>3</Zone>

<Postage>

<MailService>Priority Mail Flat Rate Box (11.25" x 8.75" x 6")</MailService>

<Rate>7.70</Rate>

</Postage>

<Postage>

<MailService>Priority Mail Flat Rate Box (14" x 12" x 3.5")</MailService>

<Rate>7.70</Rate>

</Postage>

</Package>

</RateV2Response>


CODE TO GET XML AND BIND TO DropdownList
--------------------------------------------------------

"strResponseXML"- returned XML as listed above

xmlreader = New XmlTextReader(strResponseXML, XmlNodeType.Document, Nothing)

xmlreader.Read()

Dim ds As New DataSet
ds.ReadXml(xmlreader)

DropDownList1.DataMember = "Postage"
DropDownList1.DataValueField = "Rate"
DropDownList1.DataTextField = "MailService" ''(This is were I would like to
add the Rate value as well.)

DropDownList1.DataSource = ds
DropDownList1.DataBind()


THIS IS WHAT IS CURRENTLY IN THE DROPDOWN
-----------------------------------------------------------
Priority Mail Flat Rate Box (11.25" x 8.75" x 6")
Priority Mail Flat Rate Box (14" x 12" x 3.5")


THIS IS WHAT I AM LOOKING FOR
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,534
Members
45,008
Latest member
Rahul737

Latest Threads

Top