Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8320599
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T22:42:24+00:00 2026-06-08T22:42:24+00:00

I have a ASP.NET Application with a DropDownList and I want it fill with

  • 0

I have a ASP.NET Application with a DropDownList and I want it fill with my XML File Values.
How I can I use my XML for this that I create a new item for every Value in my XML.

My XML File:

<?xml version="1.0" standalone="yes" ?>
<NewDataSet>
  <xs:schema id="NewDataSet" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
    <xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:UseCurrentLocale="true">
      <xs:complexType>
        <xs:choice minOccurs="0" maxOccurs="unbounded">
          <xs:element name="resources">
            <xs:complexType>
              <xs:sequence>
                <xs:element name="Werk" type="xs:string" minOccurs="0" />        
              </xs:sequence>
            </xs:complexType>
          </xs:element>
        </xs:choice>
      </xs:complexType>
    </xs:element>
  </xs:schema>
  <resources>
    <Werk>foo1</Werk>      <!-- The first Value-->
  </resources>
  <resources>
    <Werk>foo2</Werk>      <!-- The second Value-->
  </resources>
  <resources>
    <Werk>foo3</Werk>      <!-- The third Value-->
  </resources>
</NewDataSet>

In my ASPX:

<asp:XmlDataSource ID="XMLData" runat="server" DataFile="~/App_Data/Werke.xml" />
        <asp:DropDownList ID="dropWerk" runat="server" Width="245px" />

I need a kind of a Method that fill my DropDownList with the Data from the XML File

tarasov

CS File:

private void BindXML()
        {
          XmlDocument xmldoc = XMLData.GetXmlDocument();

          using (DataSet ds = new DataSet())
          {
              ds.ReadXml(XMLData.DataFile);
              dropWerk.DataSource = ds;
              dropWerk.DataTextField = "Werk";
              dropWerk.DataBind(); 
          }
        }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T22:42:28+00:00Added an answer on June 8, 2026 at 10:42 pm

    First Method:
    store the xml in a data set and then assign it to dropdownlist

    DataSet ds=new DataSet();
    ds.ReadXml("xmlfile.xml");
    
    dropWerk.DataSource = ds; or dropWerk.DataSource = ds.Tables[0]; 
    dropWerk.TextField = "field name"; // field to display in dropdown
    dropWerk.ValueField="Value Field";
    dropWerk.DataBind();
    

    Updated Answer:
    *2nd Method:* add one by one value to your dropdownlist items
    If I understand your question from the comments you want to add xml values to list items
    try this

    XmlDocument xdoc=new XmlDocument();
    xdoc.Load("xmlfile.xml");
    
    XmlNodeList node = xdoc.SelectSingleNodes("/NewDataSet/resources/");
    foreach(XmlNode n in node )
    {
    ListItem l = new ListItem();
        l.Text = n.InnerXml.ToString();
        drpWerk.Items.Add(l);
    }
    drpWerk.DataBind();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an ASP.NET application that uses a custom .NET library (a .DLL file).
I have a file upload function in my asp.net mvc application that allows users
I have ASP.NET webFroms application on my local, when i try to use this
I have an ASP.NET application where I use static class as cache. Inside that
ASP.NET MVC application. I have a Html.DropDownList. I want to redirect to another controller
I have an ASP.NET Application and use a ListView . This ListView has rows
I have an ASP.NET application that is hosted in timezone A and is being
I have ASP.NET MVC application that has list with jQuery Selectable list. My problem
I have a Razor view in my asp.net MVC3 application with a dropdownlist like
I have an asp net application where I use dropdown list. It is not

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.