|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
XML Dropdownlist- Custom DataTextFieldreturns 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 ---------------------------------------------- Priority Mail Flat Rate Box (11.25" x 8.75" x 6") - $7.70 Priority Mail Flat Rate Box (14" x 12" x 3.5") - $7.70 You might try adding a datacolumn, whose value is calculated by an
expression, to the table that was created after you executed this line: ds.ReadXml(xmlreader) http://msdn2.microsoft.com/en-us/library/system.data.datacolumn.expression.aspx Show quoteHide quote "Darrin" wrote: > 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 > ---------------------------------------------- > Priority Mail Flat Rate Box (11.25" x 8.75" x 6") - $7.70 > Priority Mail Flat Rate Box (14" x 12" x 3.5") - $7.70 > > > >
Gridview extra header row with command button and paging
validation message only show in val summary when ShowSummary=true when no js to execute on client Formview Question Client ID of User Control in Page templates Event from one WebControl triggering an event in another Web control HttpContext.Current.Session problem Sorting DataView problem Interactivity between placeholders & objectdatasouces radiobuttons - no list Display text with <newline> characters... |
|||||||||||||||||||||||