arraylist..or..hashtable...how to....

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • moipoimonpon
    New Member
    • Feb 2007
    • 1

    arraylist..or..hashtable...how to....

    I have the following information

    continent | country | Placeof interest

    Asia | India |agra,mumbai,de lhi
    asia | china |beijing,shanga i,shen zhen
    asia | mongolia | ulan bator
    North america | USA | new york,losangeles ,boston
    north america | canada | ottowa,toronto
    south america | brazil | sao palo,rio de janiro
    south america | argentina | comodoro,beusno air

    i want to create an aspx page that would read the data from my
    collection object and populate the dropdowns

    dropdown 1 - continent

    dropdown 2 - country

    dropdown 3 - places of interest

    so if i change asia,it should show india,china,mon golia ..in the second dropdown..if i select
    india then ythe 3rd dropdown should show all the places in india
    alone.
    thanx in advance!!
  • vijaydiwakar
    Contributor
    • Feb 2007
    • 579

    #2
    Originally posted by moipoimonpon
    I have the following information

    continent | country | Placeof interest

    Asia | India |agra,mumbai,de lhi
    asia | china |beijing,shanga i,shen zhen
    asia | mongolia | ulan bator
    North america | USA | new york,losangeles ,boston
    north america | canada | ottowa,toronto
    south america | brazil | sao palo,rio de janiro
    south america | argentina | comodoro,beusno air

    i want to create an aspx page that would read the data from my
    collection object and populate the dropdowns

    dropdown 1 - continent

    dropdown 2 - country

    dropdown 3 - places of interest

    so if i change asia,it should show india,china,mon golia ..in the second dropdown..if i select
    india then ythe 3rd dropdown should show all the places in india
    alone.
    thanx in advance!!
    i'll defenetly solve thy prob but just give me some time

    Comment

    • AricC
      Recognized Expert Top Contributor
      • Oct 2006
      • 1885

      #3
      Originally posted by moipoimonpon
      I have the following information

      continent | country | Placeof interest

      Asia | India |agra,mumbai,de lhi
      asia | china |beijing,shanga i,shen zhen
      asia | mongolia | ulan bator
      North america | USA | new york,losangeles ,boston
      north america | canada | ottowa,toronto
      south america | brazil | sao palo,rio de janiro
      south america | argentina | comodoro,beusno air

      i want to create an aspx page that would read the data from my
      collection object and populate the dropdowns

      dropdown 1 - continent

      dropdown 2 - country

      dropdown 3 - places of interest

      so if i change asia,it should show india,china,mon golia ..in the second dropdown..if i select
      india then ythe 3rd dropdown should show all the places in india
      alone.
      thanx in advance!!
      You want linked combo boxes dependent on selection? Where is the data coming from? You need to at least make an attempt at the code. Please post what you have so far.

      Comment

      • vijaydiwakar
        Contributor
        • Feb 2007
        • 579

        #4
        Originally posted by moipoimonpon
        I have the following information

        continent | country | Placeof interest

        Asia | India |agra,mumbai,de lhi
        asia | china |beijing,shanga i,shen zhen
        asia | mongolia | ulan bator
        North america | USA | new york,losangeles ,boston
        north america | canada | ottowa,toronto
        south america | brazil | sao palo,rio de janiro
        south america | argentina | comodoro,beusno air

        i want to create an aspx page that would read the data from my
        collection object and populate the dropdowns

        dropdown 1 - continent

        dropdown 2 - country

        dropdown 3 - places of interest

        so if i change asia,it should show india,china,mon golia ..in the second dropdown..if i select
        india then ythe 3rd dropdown should show all the places in india
        alone.
        thanx in advance!!
        Yeh......!
        I'm with the solution right now
        u've to use xmlfiles for that
        as
        Code:
         
        
        Imports System.Xml
        ' Place 3 comboboxes rename them as
        ' cmbContinantal,cmbCountry,cmbPlaces
        Public Class Form1
            Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
                CreateXml()
            End Sub
            Private Sub CreateXml()
                Dim myXml As New XmlTextWriter("c:\myxml.xml", System.Text.Encoding.UTF8)
                With myXml
                    .Formatting = Formatting.Indented
                    .WriteStartElement("myXml")
        
                    ' any how 0 must not be changes u may increase upto n no. 
                    'but do not increase that 0
                    .WriteStartElement("Continant")
                    .WriteAttributeString("Count01", "Asia")
                    .WriteAttributeString("Count02", "Africa")
                    .WriteEndElement()
        
                    .WriteStartElement("Country")
                    .WriteAttributeString("Asia01", "India")
                    .WriteAttributeString("Asia02", "China")
                    .WriteAttributeString("Africa01", "SA")
                    .WriteAttributeString("Africa02", "WI")
                    .WriteEndElement()
        
                    .WriteStartElement("Places")
                    .WriteAttributeString("India", "Mumbai|Delhi|Nagpur")
                    .WriteAttributeString("China", "beging|China2|China3")
                    .WriteAttributeString("SA", "sa1|sa2|sa3")
                    .WriteAttributeString("WI", "wi1|wi2|wi3")
        
                    .WriteEndElement()
                    .Flush()
                    .Close()
                End With
            End Sub
        
            Private Sub cmbContinantal_DropDown(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmbContinantal.DropDown
                SetCombosAsPer("Continant")
            End Sub
        
            Private Sub cmbContinantal_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmbContinantal.SelectedIndexChanged
                SetCombosAsPer("Country")
            End Sub
            Private Sub SetCombosAsPer(ByVal sCondition$)
                Dim Doc As New XmlDocument
                Doc.Load("C:\myxml.xml")
                Dim myNodelist As XmlNodeList
                myNodelist = Doc.GetElementsByTagName(sCondition)
                Dim myNode As XmlNode
                For Each myNode In myNodelist
                    Select Case myNode.Name
                        Case "Continant"
                            cmbContinantal.Items.Clear()
                            For i As Int16 = 0 To myNode.Attributes.Count - 1
                                cmbContinantal.Items.Add(myNode.Attributes(i).Value)
                            Next
                        Case "Country"
                            cmbCountry.Items.Clear()
        
                            For i As Int16 = 0 To myNode.Attributes.Count - 1
                                ' here 0 is concanated to avoid error.
                                'If u think how then go 3 step later and think
                                If myNode.Attributes(i).Name.Substring(0, InStr(myNode.Attributes(i).Name, "0")) = cmbContinantal.Text & "0" Then
                                    cmbCountry.Items.Add(myNode.Attributes(i).Value)
                                End If
                            Next
                        Case "Places"
                            cmbPlaces.Items.Clear()
                            Dim myCities() As String
                            For i As Int16 = 0 To myNode.Attributes.Count - 1
                                If myNode.Attributes(i).Name = cmbCountry.Text Then
                                    myCities = myNode.Attributes(i).Value.ToString.Split("|")
                                    For j As Int16 = 0 To UBound(myCities)
                                        cmbPlaces.Items.Add(myCities(j))
                                    Next
                                End If
                            Next
                    End Select
                Next
            End Sub
        
            Private Sub cmbCountry_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmbCountry.SelectedIndexChanged
                SetCombosAsPer("Places")
            End Sub
        End Class
        try it

        Comment

        Working...