Solved

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

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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

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…
Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

708 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now