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
Solved

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

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

Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

Question has a verified solution.

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

Suggested Solutions

This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

808 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