views:

42

answers:

2

Hi,

how do i bind a xml (http://www.webservicex.net/country.asmx/GetCountries) to a dropdownlist? Currently I'm working with ASP.NET 2.0.

Greetings...

A: 

First, call your web service from code behind... Then bind xml that you get from a web service to a dropdown. On this link you have how to do that:

http://forums.asp.net/t/999571.aspx

cheers

Marko
I already called Dim myGeoService As New net.webservicex.www.country Dim myISOcodes As String = myGeoService.GetCountriesBut myISOcodes is only string. The next question is how to change a string to a dataset?
GetCountries returns what?
Marko
@Marko: open in browserhttp://www.webservicex.net/country.asmx/GetCountries
ok, first you need to parse that xml and get values that you need for a dropdown:http://bytes.com/topic/visual-basic-net/answers/383280-convert-xml-string-datasetthen you can bind dataset to a dropdowncheers
Marko
+1  A: 

thx Marko, finally:

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    Dim myGeoService As New net.webservicex.www.country
    Dim myISOcodes As String = myGeoService.GetCountries

    Dim reader As New System.IO.StringReader(myISOcodes)

    If Not Page.IsPostBack Then
        Dim mycountries As New DataSet
        mycountries.ReadXml(reader)
        DropDownList1.DataSource = mycountries
        'DropDownList1.DataValueField = "value"
        DropDownList1.DataTextField = "Name"
        DropDownList1.DataBind()
    End If

End Sub
I'm glad I've helped...cheers
Marko