Solved

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

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
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…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

733 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