嗨,我在我的代码生成隐藏文件从代码生成的DropDownList后面
protected DropDownList CountryList()
{
DropDownList ddl = new DropDownList();
XDocument xmlDoc = XDocument.Load(Server.MapPath("Countries.xml"));
var countries = from country in xmlDoc.Descendants("Country")
select new
{
Name = country.Element("name").Value,
};
foreach (var c in countries)
{
ddl.Items.Add(c.Name);
}
return ddl;
}
一个DropDownList我有那么有我的aspx页面上<%= CountryList()%>的梦想。但是当我这样做时,它会打印字符串 - “System.Web.UI.WebControls.DropDownList”。
我可以使这种方式做到这一点吗?或者我必须设置ContentPlaceHolder,然后将DropDownList添加到内容中吗?
干杯
欢呼的评论 谢谢 – Marklar 2009-06-15 05:31:44