title: bind dropdownlist using XML
body: <p>i am new to ASP.NET,</p>
  
  <p>i am making Country, state dropdownlist.</p>
  
  <p>for eg: For particular country, i will read states of that country from XML file.</p>
  
  <p>here is my code snippet in <code>XMLFile.xml</code></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt;
  &lt;countrys&gt;
  
    &lt;country&gt;India&lt;/country&gt;
    &lt;state&gt;
      &lt;text&gt;Maharashtra&lt;/text&gt;
      &lt;text&gt;Kashmir&lt;/text&gt;
      &lt;text&gt;Goa&lt;/text&gt;   
    &lt;/state&gt;
  
    &lt;country&gt;Sri Lanka&lt;/country&gt;
    &lt;state&gt;
      &lt;text&gt;Kanady&lt;/text&gt;
      &lt;text&gt;Colombo&lt;/text&gt;
      &lt;text&gt;Galle&lt;/text&gt; 
    &lt;/state&gt;
  
    &lt;country&gt;Australia&lt;/country&gt;
    &lt;state&gt;
      &lt;text&gt;Sydney&lt;/text&gt;
      &lt;text&gt;Perth&lt;/text&gt;
      &lt;text&gt;Melbourne&lt;/text&gt;
    &lt;/state&gt;
  
    &lt;country&gt;South Africa&lt;/country&gt;
    &lt;state&gt;
      &lt;text&gt;Capetown&lt;/text&gt;
      &lt;text&gt;Johanusburg&lt;/text&gt;
      &lt;text&gt;Durban&lt;/text&gt;
    &lt;/state&gt;
  &lt;/countrys&gt;
  </code></pre>
  
  <p>and code in <code>Country.aspx.cs</code></p>
  
  <pre><code>   public partial class Country : System.Web.UI.Page
     {
         protected void Page_Load(object sender, EventArgs e)
         {
  
              if (!IsPostBack)
              {
                  LoadDropdown();
              }
       }
  
      protected void LoadDropdown()
      {
              DataSet ds = new DataSet();
              ds.ReadXml (Server.MapPath("XMLFile.xml"));
  
              DropDownListCountry.DataTextField = "country";
  
              DropDownListCountry.DataSource = ds;
              DropDownListCountry.DataBind();
              DropDownListCountry.Items.Insert(0,new ListItem(" Select ","0"));
          }
       }
  
      protected void DropDownListCountry_SelectedIndexChanged(object sender, EventArgs e)
      {
              string  st = (DropDownListCountry.SelectedIndex).ToString();
  
               XDocument main = XDocument.Load(@"XMLFile.xml");
  
          var query = from user in main.Descendants("country_text")
                  where st == user.Element("state").Value
                  select user;
  
          DropDownListState.DataSource = query;
          DropDownListState.DataBind();     
      }
  }
  </code></pre>
  
  <p><strong>ERROR :</strong>  DataBinding: 'System.Data.DataRowView' does not contain a property with the name 'country'. </p>