Reputation: 15
i am having trouble in populating dataset in DropDownList1 from http://www.webservicex.net/country.asmx/GetCountries however, my dropdownlist shows data in char format https://i.sstatic.net/Dxbyq.jpg and im not sure why.
country count = new country(); //from Service
DropDownList1.DataSource = count.GetCountries();
DropDownList1.DataBind();
Upvotes: 0
Views: 233
Reputation: 2053
Seems like your asmx service is providing the xml and you are directly trying to bind it with dropdown, which is incorrect.
you need to convert the xml to dataset and then try to bind.
string xmlFile = count.GetCountries();
DataSet dataSet = new DataSet();
dataSet.ReadXml(xmlFile, XmlReadMode.InferSchema);
DropDownList1.DataSource = dataSet OR dataSet.Tables[0];
DropDownList1.DataTextField = "Name";
DropDownList1.DataBind();
Upvotes: 1