我在http:///www.webservicex.net/country.asmx/getCountries中遇到dropdownlist1中的数据集时遇到麻烦.stack.imgur.com/dxbyq.jpg,我不确定为什么。
country count = new country(); //from Service
DropDownList1.DataSource = count.GetCountries();
DropDownList1.DataBind();
似乎您的ASMX服务正在提供XML,并且您直接尝试将其与下拉订单绑定,这是不正确的。
您需要将XML转换为数据集,然后尝试绑定。
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();