Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


c# setting up combo box using xml as datasource. How do I make DisplayMember and valueMember attributes of a xml node

Posted on 2011-02-28
Medium Priority
Last Modified: 2012-05-11
c# setting up combo box using xml as datasource. How do I make DisplayMember and valueMember attributes of a xml node
Question by:peter3244
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
  • 3
  • 2
LVL 20

Expert Comment

by:Daniel Van Der Werken
ID: 34998122
Well, we don't have your XML source, but here's a go at this:

You'd grab the document and load it as an XmlDocument:

XmlDocument xDoc = new XmlDocument();
xDox.Load( xmlSource -- whatever that is );

Then, you'd grab all the nodes of interest:

XmlNodeCollection xmlNodes = xDoc.GetNodes( xpathToNodes );

Then, loop through the nodes, getting the values you want:

foreach( XmlNode node in xmlNodes )
   string value1 = node.SelectSingleNode( xpath );
   combobox.Items.Add( value1 );

...more or less.
LVL 11

Expert Comment

by:Sudhakar Pulivarthi
ID: 34998136

Your xml should be:

Display Member is DriverName
Value Member is EmployeeId

Use like this in ur scenario too.
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.


Accepted Solution

peter3244 earned 0 total points
ID: 34998802
No because you are talking about nodes not atrributes.  However if you I have discovered through trail and error
that it can be done using a dataset

            cmbField.DataSource = ds.Tables["field"];
            cmbField.DisplayMember = "name";

where field is a node and name is an attribute.

Author Comment

ID: 34998832
Sorry  I meant to say that all the coomet relate to nodes not attributes.

Author Closing Comment

ID: 35042604

1) The first was a cut and paste of a link
2) the other was incorrect

Featured Post

Tech or Treat!

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

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

Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

618 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