?
Solved

VB.NET : Dataset : Combo box's showing parent child relationship with XML datasource

Posted on 2004-03-26
3
Medium Priority
?
1,417 Views
Last Modified: 2012-05-04
This should be fairly simple for many of you.

I have a configuration file (XML) that contains connection informatin.
I have no problem reading the data, or displaying it in a datagrid.

What I want to do is show server Names in one combo box. Then the corresponding list of user names in another combo box. This data is all in the xml file.

Example format of XML config file:
--------------------------------------------------------------------------------------------
<?xml version="1.0" standalone="yes"?>
<configuration>
  <ServerName Name="SomeName">
    <Login>
      <Username>user1</Username>
      <Password>password1</Password>
    </Login>
    <Login>
      <Username>user2</Username>
      <Password>password2</Password>
    </Login>
    <Login>
      <Username>user3</Username>
      <Password>password3</Password>
    </Login>
  </ServerName>
  <ServerName Name="AnotherServer">
    <Login>
      <Username>user1</Username>
      <Password>password1</Password>
    </Login>
    <Login>
      <Username>user2</Username>
      <Password>password2</Password>
    </Login>
    <Login>
      <Username>user3</Username>
      <Password>password3</Password>
    </Login>
  </ServerName>
</configuration>
--------------------------------------------------------------------------------------------

Here is what I've been doing to get the data.

--------------------------------------------------------------------------------------------

        Dim DS As DataSet
        Dim DV As DataView
        DS = New DataSet()
        DS.ReadXml(ConfigFile)
        DV = New DataView(DS.Tables("ServerName"))
        cmboServerName.DataSource = DV
        cmboServerName.DisplayMember = "Name"

--------------------------------------------------------------------------------------------

This works in populating cmboServerName with the list of available servers (from config file)

What I want to do next is tie a second combo box to the Usernames that are available for the selected server in cmboServerName.

What is the best way of doing this and how would I impliment it?

Thanks,
Tony
0
Comment
Question by:mytonytiger
[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
3 Comments
 
LVL 12

Accepted Solution

by:
dfiala13 earned 2000 total points
ID: 10689151
cmboServerName.ValueMember = "ServerName_Id"

DV1 = New DataView(DS.Tables("Login"))
DV1.RowFilter ="ServerName_Id = " cmboServerName.SelectedValue
cmboUserName.DataSource = DV1
cmboUserName.DisplayMember = "Username"

You'll want to call the code to update what's display in cmboUserName. whenver the selection in cmboServerName is changed.
0
 
LVL 5

Author Comment

by:mytonytiger
ID: 10689326
Thank you very much.
0
 
LVL 12

Expert Comment

by:dfiala13
ID: 10689370
You're welcome.
0

Featured Post

Give Your Engineering Team a Productivity Boost

Learn why container technology is so powerful and how it can provide your team with productivity gains and other benefits.

Question has a verified solution.

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

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Suggested Courses

771 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