protected void Page_Load(object sender, EventArgs e) { var service = new net.webservicex.www.country(); var xml = service.GetCountries(); var countries = XDocument.Parse(xml).Descendants("Name").Select(arg => arg.Value).ToList(); countriesDropDownList.DataSource = countries; countriesDropDownList.DataBind(); }
protected void PopulateDropDowns() { string[] months = { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" }; string[] years = { "2011", "2012", "2013", "2014", "2015", "2016", "2017", "2018", "2019", "2020", "2021", "2022", "2023", "2024", "2025", "2026", "2027", "2028", "2029", "2030" }; string[] states = { "AK", "AL", "AR", "AZ", "CA", "CO", "CT", "DC", "DE", "FL", "GA", "HI", "IA", "ID", "IL", "IN", "KS", "KY", "LA", "MA", "MD", "ME", "MI", "MN", "MO", "MS", "MT", "NC", "ND", "NE", "NH", "NJ", "NM", "NV", "NY", "OH", "OK", "OR", "PA", "RI", "SC", "SD", "TN", "TX", "UT", "VT", "WA", "WI", "WV", "WY", "AA", "AE", "AP" }; ddlMonths.DataSource = months; ddlMonths.DataBind(); ddlYears.DataSource = years; ddlYears.DataBind(); ddlStates.DataSource = states; ddlStates.DataBind(); //consume the getcountries web service and bind to the countries ddl var service = new net.webservicex.www.country(); var xml = service.GetCountries(); var countries = XDocument.Parse(xml).Descendants("Name").Select(arg => arg.Value).ToList(); ddlCountries.DataSource = countries; ddlCountries.DataBind(); }
protected void PopulateDropDowns() { string[] months = { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" }; string[] years= { "2011", "2012", "2013", "2014", "2015", "2016", "2017", "2018", "2019", "2020", "2021", "2022", "2023", "2024", "2025", "2026", "2027", "2028", "2029", "2030" }; string[] states = { "AK", "AL", "AR", "AZ", "CA", "CO", "CT", "DC", "DE", "FL", "GA", "HI", "IA", "ID", "IL", "IN", "KS", "KY", "LA", "MA", "MD", "ME", "MI", "MN", "MO", "MS", "MT", "NC", "ND", "NE", "NH", "NJ", "NM","NV", "NY", "OH", "OK", "OR", "PA", "RI", "SC", "SD", "TN", "TX", "UT", "VT", "WA", "WI", "WV", "WY", "AA", "AE", "AP" }; ddlMonths.DataSource = months; ddlMonths.DataBind(); ddlYears.DataSource = years; ddlYears.DataBind(); ddlStates.DataSource = states; ddlStates.DataBind(); //consume the getcountries web service and bind to the countries ddl var service = new net.webservicex.www.country(); var xml = service.GetCountries(); var countries = XDocument.Parse(xml).Descendants("Name").Select(arg => arg.Value).ToList(); ddlCountries.DataSource = countries; ddlCountries.DataBind(); }