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

  • Home
  • SEARCH
  • 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 7049419
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:00:44+00:00 2026-05-28T03:00:44+00:00

Hi i am trying to load XML document and populate few checkboxlist. I use

  • 0

Hi i am trying to load XML document and populate few checkboxlist. I use DataTextField as below.

    <asp:CheckBoxList ID="cblcountry" runat="server" DataTextField="CountryofBirth">

And in the code behind i use this code below.

    Dim dSet As New DataSet
    dSet.ReadXml(Server.MapPath("xsource.xml"))
    cblcountry.DataSource = dSet
    cblcountry.DataBind()

And this is xml doc.

    <pupil>
    <academicYear>2011/2010</academicYear>
    <grade>Kindergarten 1</grade>
    <class>class 1</class>    
    <name>emma</name>
    <admissionDate>01/05/2010</admissionDate>
    <CountryofBirth>United Kingdom</CountryofBirth>
    <fullName>emma watson</fullName>
    </pupil>

It loads everything fine. But it has duplicated items. For example, if there are 5 people with CountryofBirth is United Kingdom than checkboxlist show it 5 times. If i delete CountryofBirth from 1 block of XML, it still shows a blank checkboxitem.

So my question is how do i get checkboxlist without showing those duplicated data. I am just developing a prototype (working demo) so easiest way would be more appreciated.

Thanks so much guys. I love this forum.

  • 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-05-28T03:00:44+00:00Added an answer on May 28, 2026 at 3:00 am

    The drop down list will add a list item for every Puplil element in the XML document. You should first filter the XML (or dataset) to a distinct list of countries and then bind to the drop down list control.

    Edit w/ Linq Example:

    First, remove the DataTextField=”CountryofBirth” from your Aspx Page.

    Second…

        Dim dSet As New DataSet
        dSet.ReadXml(Server.MapPath("xsource.xml"))
    
        Dim lstCountries As List(Of String) = (From dr As DataRow In ds.Tables(0).Rows _
                                               Select CStr(dr.Item("CountryofBirth"))).Distinct.ToList()
    
        cblcountry.DataSource = lstCountries
        cblcountry.DataBind()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to load an XML document which is in Project\Data as shown below:
I am trying to load a xml document I created using PHP and DOM
I am trying to load a very basic XML document but everytime I get
I'm trying to parse and load an XML document, however I'm getting this exception
I'm trying to use the following code # LOAD XML FILE $XML = new
I'm trying to load a xml document into an object XPathDocument in C#. My
I'm trying to load a document with xml in c# the name of xml
I am trying to load a 3rd party xml document using JQuery/Javascript, but without
I am trying to use jQuery to parse an in-memory XML document. This works
Trying to load some XML into a document: <Custom AttributeA='' AttributeB='Bob' AttributeC='HUNTERS' COMPANY EMPLOYEES'

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.