Hi I am generating a DropDownList in my code behind file
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;
}
I had dreams on then having <%= CountryList() %> on my aspx page. But when I do this it prints the string - "System.Web.UI.WebControls.DropDownList".
Can I make this way of doing it work or do I have to setup a ContentPlaceHolder and then add the DropDownList to the content?
Cheers