Solved

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

Posted on 2004-03-26
3
1,410 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 500 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

Containers & Docker to Create a Powerful Team

Containers are an incredibly powerful technology that can provide you and/or your engineering team with huge productivity gains. Using containers, you can deploy, back up, replicate, and move apps and their dependencies quickly and easily.

Question has a verified solution.

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

Flash (http://en.wikipedia.org/wiki/Adobe_Flash) has evolved over the years to where it has become a masterful tool for displaying content screen.  It has excellent layout placement, UI precision as well as rendering capabilities. This, along with t…
The object model of .Net can be overwhelming at times – so overwhelming that quite trivial tasks often take hours of research. In this case, the task at hand was to populate the datagrid from SQL Server database in Visual Studio 2008 Windows applica…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

719 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