title: Binding an xml node's children to ASP.Net DropDownList
body: <p>I'm trying to bind the contents of a node of XML to a Drop Down List without much success.</p>
  
  <p>Initially, the whole XML document is bound to a repeater - this works perfectly, <em>but</em> now I need to display a drop down list based on the children in the "" node, but I get Data at the root level is invalid. Line 1, position 1 error message on the DataBind() method on the dropDownList.</p>
  
  <p>Can anyone tell me what I'm doing wrong please??</p>
  
  <p>The code snippet I'm using is:</p>
  
  <pre><code>    IXPathNavigable x = (IXPathNavigable)e.Item.DataItem;
      XPathNavigator questionNode = x.CreateNavigator();
     string question = questionNode.SelectSingleNode("questionText").ToString();
  
     //string title = xePage.SelectSingleNode("q").InnerText;
  
      Literal questionText = (Literal)e.Item.FindControl("litQuestionText");
      questionText.Text = question;
      Panel iconDiv = (Panel)e.Item.FindControl("divIcon");
      iconDiv.CssClass = string.Format("icon {0}", questionNode.SelectSingleNode("iconType"));
      Panel sliderPanel = (Panel)e.Item.FindControl("pnlSlider");
      DropDownList answerDropDown = (DropDownList)e.Item.FindControl("ddlAnswer");
      TextBox answerText = (TextBox)e.Item.FindControl("txtAnswer");
  
      switch (questionNode.SelectSingleNode("answerType").ToString())
      {
          case "d": 
              sliderPanel.Visible = false;
              answerText.Visible = false;
              answerDropDown.Visible = true;
  
              XmlDataSource answersList = new XmlDataSource();
              answersList.Data = questionNode.Select("answers").ToString();
              Response.Write(answersList.ToString());
              //XPathNodeIterator answers = questionNode.Select("answers");
              //answers.AsQueryable();
              answersList.ID = questionNode.SelectSingleNode("questionId").ToString();
              answerDropDown.DataSource = answersList;
              answerDropDown.DataTextField = "@display";
              answerDropDown.DataValueField = "@value";
              answerDropDown.DataBind();
              break;
  
          case "s":
              sliderPanel.Visible = true;
              answerText.Visible = false;
              answerDropDown.Visible = false;
              break;
          case "t":
              sliderPanel.Visible = false;
              answerText.Visible = true;
              answerDropDown.Visible = false;
              break;
  </code></pre>
  
  <p>and the XML I'm using is thus:</p>
  
  <pre><code>&lt;questions&gt;
    &lt;question&gt;
      &lt;questionId&gt;1&lt;/questionId&gt;
      &lt;questionText&gt;Question here?&lt;/questionText&gt;
      &lt;iconType&gt;a&lt;/iconType&gt;
      &lt;answerType&gt;d&lt;/answerType&gt;
      &lt;answers&gt;
        &lt;answer value="-3" display="Extremely badly"/&gt;
        &lt;answer value="-2" display="Very badly"/&gt;
        &lt;answer value="-1" display="Quite badly"/&gt;
        &lt;answer value="0" display="Neither well nor badly"/&gt;
        &lt;answer value="1" display="Quite well"/&gt;
        &lt;answer value="2" display="Very well"/&gt;
        &lt;answer value="3" display="Extremely well"/&gt;
      &lt;/answers&gt;
    &lt;/question&gt;
    &lt;question&gt;
      &lt;questionId&gt;1&lt;/questionId&gt;
      &lt;questionText&gt;Question again here?&lt;/questionText&gt;
      &lt;iconType&gt;b&lt;/iconType&gt;
      &lt;answerType&gt;s&lt;/answerType&gt;
      &lt;answers/&gt;
    &lt;/question&gt;
  &lt;/questions&gt;
  </code></pre>