Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Populate Combobox with Simple XML or Text File

Posted on 2004-08-25
4
Medium Priority
?
747 Views
Last Modified: 2008-03-06
Please submit VB.NET code for examples, I'm familiar and use C# from time to time but I'm most familiar with VB.NET.

I would like to know how to populate a ComboBox with data from an XML file or delimited text file as shown below:

XML

<templates>
    <template>
        <name>MyTemplate</name>
        <path>MyTemplatePath</path>
    </template>
</templates>

Plain Text Tab Delimited

Mytemplate       MyTemplatePath

Thanks in advanced.
0
Comment
Question by:brian2k1
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 28

Accepted Solution

by:
mmarinov earned 2000 total points
ID: 11889772
Hi,

use this:

        If Not IsPostBack Then
            Dim _ds As DataSet = New DataSet
            _ds.ReadXml(Request.ServerVariables("APPL_PHYSICAL_PATH") & "/XMLFile1.xml")
            DropDownList1.DataSource = _ds.Tables(0)
            DropDownList1.DataTextField = "name"
            DropDownList1.DataValueField = "path"
            DropDownList1.DataBind()
        End If

Regards,
B..M
0
 
LVL 1

Author Comment

by:brian2k1
ID: 11889890
I posted in the wrong category this was a VB.NET project using WinForms so it is a combo box not a dropdownlist. Do you know the way to use the ComboBox in the same way?

Thanks.
0
 
LVL 28

Expert Comment

by:mmarinov
ID: 11889906
the way is absolutelly the same, just you have to replace DataTextField with DisplayMember
DataValueMember with ValueMember and skip the DataBind() method

Regards,
B..M
0
 
LVL 1

Author Comment

by:brian2k1
ID: 11889944
Awesome! Thanks very much. I knew it was that simple but I couldn't find any good examples.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question