Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 574
  • Last Modified:

Help with loading multiple listboxes with filtered data

Hi,

This is a followup from the following issue:

http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/Q_27827475.html#a38307414

and Listed below is the link to the application I tried to modify.

http://speedy.sh/b5hYH/xmlUpdateTest.zip

I am trying to add another list box to the project but no data is dislayed, can you please to see what is wrong with the code.

Thanks,

Victor
0
vcharles
Asked:
vcharles
  • 7
  • 2
  • 2
1 Solution
 
teebonProduct ManagerCommented:
Hi Victor,

Unable to download your file without having a registered accound.
Can you upload to another file server?
0
 
vcharlesAuthor Commented:
Hi,

Do you another link i can use to upload this file free of charge?

Victor
0
 
teebonProduct ManagerCommented:
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
vcharlesAuthor Commented:
Hi,

Below is my code, all working ok before I tried to also list data in the country listbox, now C!NSN listbox does not show any data. I added tablea, dtKeymaster(rowId) (3) and keyCountry to see data in the country lstbox, but apparently it is also causing the NSN part not to work.


Imports System.Xml
Imports System
Imports System.Text
Imports C1.Web.UI.Controls.C1ComboBox
Imports C1.Web.UI.Controls.C1Input
Imports System.IO
Imports System.Data
'Please understand that, i never did for next action i want to be 100% percent sure that on changing dropdown the multiple option checkbox and single details listbox is being selected is exactly what you require is.

Partial Class WebForm1
    Inherits System.Web.UI.Page
    Public CurrentIndex As Integer
    Dim dtMaster As DataTable
    Dim dtCountry As DataTable
    Dim dtKeyMaster As DataTable
    'C1Fuze - is First dropdwn
    'C1NSN - IS first Listbox
    'C1SDeactivation - is second ddl

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        loadfile()
    End Sub

    Protected Sub C1Fuze_SelectedIndexChanged(ByVal sender As Object, ByVal args As C1.Web.UI.Controls.C1ComboBox.C1ComboBoxEventArgs) ' Handles C1Fuze.SelectedIndexChanged
        SearchFuze1()
    End Sub

    Public Function SearchFuze1()
        'Declaration XmlDocuments
        Dim xdLink As New Xml.XmlDocument
        Dim xdLinkA As New Xml.XmlDocument
        Dim xdNSN As New Xml.XmlDocument
        Dim xdCountry As New Xml.XmlDocument
        Dim xdSDeactivation As New Xml.XmlDocument
        ' load XML documents
        xdLink.Load(Server.MapPath("~/App_Data/LinkSSADB.xml"))
        xdLinkA.Load(Server.MapPath("~/App_Data/LinkA.xml"))
        xdNSN.Load(Server.MapPath("~/App_Data/NSN.xml"))
        xdCountry.Load(Server.MapPath("~/App_Data/Country.xml"))
        xdSDeactivation.Load(Server.MapPath("~/App_Data/SDeactivation.xml"))
        'Declare variables
        Dim Name As String
        Dim NSNID As String
        Dim fuze_Nsn_id As String

        Dim CountryID As String
        Dim fuze_Country_id As String

        Dim LinkAID As String
        Dim SDeactivation_ID As String, SDeactivation As String
        Dim SDeactivationID As String
        Dim NSNID2 As String
        Dim CountryID2 As String
        Dim SDeactivationID2 As String
        Dim Link_ID As String, LinkID2 As String
        Dim utubec As String
        dtMaster = New DataTable
        dtMaster.Columns.Add("FUZE_NSN_ID", GetType(String))

        dtMaster.Columns.Add("FUZE_Country_ID", GetType(String))

        dtMaster.Columns.Add("LinkAID", GetType(String))
        dtMaster.Columns.Add("NSN_ID", GetType(String))
        dtMaster.Columns.Add("NSN", GetType(String))

        dtMaster.Columns.Add("Country_ID", GetType(String))
        dtMaster.Columns.Add("Country", GetType(String))


        dtMaster.Columns.Add("SDeactivation_ID", GetType(String))
        dtMaster.Columns.Add("SDeactivation", GetType(String))
        dtKeyMaster = New DataTable
        dtKeyMaster.Columns.Add("rowId", GetType(String))
        dtKeyMaster.Columns.Add("keyLinkAid", GetType(String))
        dtKeyMaster.Columns.Add("keyNsn", GetType(String))
        dtKeyMaster.Columns.Add("keyCountry", GetType(String))

        Dim rowIndex As Integer = 1
        For Each xnLink As Xml.XmlNode In xdLink.SelectNodes("/Root/LinkA[Fuze_ID='" & C1Fuze.SelectedItem.Value & "']") 'linkssadb.xml
            Link_ID = xnLink.SelectSingleNode("LinkAID").InnerText
            NSNID = xnLink.SelectSingleNode("NSN_ID").InnerText
            CountryID = xnLink.SelectSingleNode("NSN_ID").InnerText
            fuze_Nsn_id = NSNID
            fuze_Country_id = CountryID
            LinkAID = Link_ID
            'List Box Load With matching fuze id in linkssadb.xml - Starts
            For Each xnNSN As Xml.XmlNode In xdNSN.SelectNodes("/Root/NSNTable[contains('," & NSNID & ",', concat(',', NSN_ID, ','))]") 'NSN.xml
                NSNID2 = xnNSN.SelectSingleNode("NSN_ID").InnerText
                Name = xnNSN.SelectSingleNode("NSN").InnerText
                dtMaster.Rows.Add({fuze_Nsn_id, LinkAID, NSNID2, Name})
            Next


            For Each xnCountry As Xml.XmlNode In xdCountry.SelectNodes("/Root/CountryTable[contains('," & CountryID & ",', concat(',', Country_ID, ','))]") 'Country.xml
                CountryID2 = xnCountry.SelectSingleNode("Country_ID").InnerText
                Name = xnCountry.SelectSingleNode("Country").InnerText
                dtMaster.Rows.Add({fuze_Country_id, LinkAID, CountryID2, Name})
            Next

            MsgBox(dtMaster.Rows.Count)
            'List Box Load With matching fuze id in linkssadb.xml - Ends
            LinkID2 = xnLink.SelectSingleNode("LinkAID").InnerText 'linkssadb.xml
            Session("currentIndex") = 0
            For Each xnLinkA As Xml.XmlNode In xdLinkA.SelectNodes("/Root/LinkA[LinkAID='" & LinkID2 & "']") 'LinkA.xml
                SDeactivationID = xnLinkA.SelectSingleNode("SDeactivation_ID").InnerText
                For Each xnSDeactivation As Xml.XmlNode In xdSDeactivation.SelectNodes("/Root/SDeactivationTable[contains('," & SDeactivationID & ",', concat(',', SDeactivation_ID, ','))]") 'xdSDeactivation.xml
                    Name = xnSDeactivation.SelectSingleNode("SDeactivation").InnerText
                    If utubec = "" Then
                        utubec = Name
                    Else
                        If utubec.Split(",").Contains(Name) = False Then
                            utubec = utubec & "," & Name
                        End If
                    End If
                Next
            Next
            For Each row In dtMaster.Select("LinkAID = " & LinkID2)
                row("SDeactivation") = utubec
            Next
            dtMaster.AcceptChanges()
            utubec = ""
            dtKeyMaster.Rows.Add({rowIndex, LinkAID, fuze_Nsn_id, fuze_Country_id})
            rowIndex += 1
        Next
        Response.Write("Your utubec is : " & utubec)
        Session("dtMaster") = dtMaster
        Session("dtKeyMaster") = dtKeyMaster
        If dtMaster.Rows.Count >= 1 Then
            ViewData(dtKeyMaster.Rows(0)(1), dtKeyMaster.Rows(0)(2), dtKeyMaster.Rows(0)(3))
        End If
    End Function
    Private Sub ViewData(ByVal keyLinkAid As String, ByVal keyNsn As String, ByVal keyCountry As String)
        MsgBox("View")
        Dim utubec As String = ""
        MsgBox(keyLinkAid)
        ' MsgBox(SDeactivation)
        ' Dim utubec As String = ""
        For Each row In dtMaster.Select("LinkAID = " & keyLinkAid & " and SDeactivation <> ''")
            utubec = row("SDeactivation")
        Next
        Dim SDeactivation As New DataSet
        SDeactivation.ReadXml(Server.MapPath("~/App_Data/SDeactivation.xml"))
        C1SDeactivation.DataSource = SDeactivation.Tables(0)
        C1SDeactivation.DataTextField = "SDeactivation"
        C1SDeactivation.DataValueField = "SDeactivation_ID"
        C1SDeactivation.DataBind()
        C1SDeactivation.ClearSelection()
        For i As Integer = 0 To C1SDeactivation.Items.Count - 1
            If utubec.Split(",").Contains(C1SDeactivation.Items(i).Text) Then
                C1SDeactivation.Items(i).Selected = True
                Dim CB As CheckBox = C1SDeactivation.Items(i).FindControl("CheckSDeactivation")
                CB.Checked = True
            End If
        Next

        Dim _table As DataView = dtMaster.DefaultView
        _table.RowFilter = "NSN_ID in (" & keyNsn & ")"
        C1NSN.DataSource = _table
        C1NSN.DataTextField = "NSN"
        C1NSN.DataValueField = "NSN_ID"
        C1NSN.DataBind()

        Dim _tablea As DataView = dtMaster.DefaultView
        _tablea.RowFilter = "Country_ID in (" & keyCountry & ")"
        C1Country.DataSource = _tablea
        C1Country.DataTextField = "Country"
        C1Country.DataValueField = "Country_ID"
        C1Country.DataBind()
    End Sub

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
        dtMaster = Session("dtMaster")
        dtKeyMaster = Session("dtKeyMaster")
        Dim rowId As Integer = Session("currentIndex") + 1
        ViewData(dtKeyMaster.Rows(rowId)(1), dtKeyMaster.Rows(rowId)(2), dtKeyMaster.Rows(rowId)(3))
    End Sub
    Private Sub loadfile()
        If IsPostBack = False Then
            Dim Fuze As New DataSet
            C1Fuze.Items.Clear()
            Fuze.ReadXml(Server.MapPath("~/App_Data/Fuze.xml"))
            C1Fuze.DataSource = Fuze.Tables(0)
            C1Fuze.DataMember = "Fuze"
            C1Fuze.DataTextField = "Fuze"
            C1Fuze.DataValueField = "Fuze_ID"
            C1Fuze.DataBind()

            Dim SDeactivation As New DataSet
            SDeactivation.ReadXml(Server.MapPath("~/App_Data/SDeactivation.xml"))
            C1SDeactivation.DataSource = SDeactivation.Tables(0)
            C1SDeactivation.DataTextField = "SDeactivation"
            C1SDeactivation.DataValueField = "SDeactivation_ID"
            C1SDeactivation.DataBind()

            Dim Country As New DataSet
            Country.ReadXml(Server.MapPath("~/App_Data/Country.xml"))
            C1Country.DataSource = Country.Tables(0)
            C1Country.DataTextField = "Country"
            C1Country.DataValueField = "Country_ID"
            C1Country.DataBind()
        End If
    End Sub

    Protected Sub Button2_Click(sender As Object, e As System.EventArgs) Handles Button2.Click
        dtMaster = Session("dtMaster")
        dtKeyMaster = Session("dtKeyMaster")
        Dim rowId As Integer
        If Session("currentIndex") >= 1 Then
            rowId = Session("currentIndex") - 1
        Else
            rowId = 0
        End If
        ViewData(dtKeyMaster.Rows(rowId)(1), dtKeyMaster.Rows(rowId)(2), dtKeyMaster.Rows(rowId)(3))
        Session("currentIndex") = rowId

    End Sub
End Class
0
 
vcharlesAuthor Commented:
Hi,

Below is the original code that worked with one listbox.

Imports System.Xml
Imports System
Imports System.Text
Imports C1.Web.UI.Controls.C1ComboBox
Imports C1.Web.UI.Controls.C1Input
Imports System.IO
Imports System.Data
'Please understand that, i never did for next action i want to be 100% percent sure that on changing dropdown the multiple option checkbox and single details listbox is being selected is exactly what you require is.

Partial Class WebForm1
    Inherits System.Web.UI.Page
    Public CurrentIndex As Integer
    Dim dtMaster As DataTable
    Dim dtAmmoType As DataTable
    Dim dtKeyMaster As DataTable
    'C1Fuze - is First dropdwn
    'C1NSN - IS first Listbox
    'C1SDeactivation - is second ddl

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        loadfile()
    End Sub

    Protected Sub C1Fuze_SelectedIndexChanged(ByVal sender As Object, ByVal args As C1.Web.UI.Controls.C1ComboBox.C1ComboBoxEventArgs) ' Handles C1Fuze.SelectedIndexChanged
        SearchFuze1()
    End Sub

    Public Function SearchFuze1()
        'Declaration XmlDocuments
        Dim xdLink As New Xml.XmlDocument
        Dim xdLinkA As New Xml.XmlDocument
        Dim xdNSN As New Xml.XmlDocument
        Dim xdSDeactivation As New Xml.XmlDocument
        ' load XML documents
        xdLink.Load(Server.MapPath("~/App_Data/LinkSSADB.xml"))
        xdLinkA.Load(Server.MapPath("~/App_Data/LinkA.xml"))
        xdNSN.Load(Server.MapPath("~/App_Data/NSN.xml"))
        xdSDeactivation.Load(Server.MapPath("~/App_Data/SDeactivation.xml"))
        'Declare variables
        Dim Name As String
        Dim NSNID As String
        Dim fuze_Nsn_id As String
        Dim LinkAID As String
        Dim SDeactivation_ID As String, SDeactivation As String
        Dim SDeactivationID As String
        Dim NSNID2 As String
        Dim SDeactivationID2 As String
        Dim Link_ID As String, LinkID2 As String
        Dim utubec As String
        dtMaster = New DataTable
        dtMaster.Columns.Add("FUZE_NSN_ID", GetType(String))
        dtMaster.Columns.Add("LinkAID", GetType(String))
        dtMaster.Columns.Add("NSN_ID", GetType(String))
        dtMaster.Columns.Add("NSN", GetType(String))
        dtMaster.Columns.Add("SDeactivation_ID", GetType(String))
        dtMaster.Columns.Add("SDeactivation", GetType(String))
        dtKeyMaster = New DataTable
        dtKeyMaster.Columns.Add("rowId", GetType(String))
        dtKeyMaster.Columns.Add("keyLinkAid", GetType(String))
        dtKeyMaster.Columns.Add("keyNsn", GetType(String))
        Dim rowIndex As Integer = 1
        For Each xnLink As Xml.XmlNode In xdLink.SelectNodes("/Root/LinkA[Fuze_ID='" & C1Fuze.SelectedItem.Value & "']") 'linkssadb.xml
            Link_ID = xnLink.SelectSingleNode("LinkAID").InnerText
            NSNID = xnLink.SelectSingleNode("NSN_ID").InnerText
            fuze_Nsn_id = NSNID
            LinkAID = Link_ID
            'List Box Load With matching fuze id in linkssadb.xml - Starts
            For Each xnNSN As Xml.XmlNode In xdNSN.SelectNodes("/Root/NSNTable[contains('," & NSNID & ",', concat(',', NSN_ID, ','))]") 'NSN.xml
                NSNID2 = xnNSN.SelectSingleNode("NSN_ID").InnerText
                Name = xnNSN.SelectSingleNode("NSN").InnerText
                dtMaster.Rows.Add({fuze_Nsn_id, LinkAID, NSNID2, Name})
            Next
            'List Box Load With matching fuze id in linkssadb.xml - Ends
            LinkID2 = xnLink.SelectSingleNode("LinkAID").InnerText 'linkssadb.xml
            Session("currentIndex") = 0
            For Each xnLinkA As Xml.XmlNode In xdLinkA.SelectNodes("/Root/LinkA[LinkAID='" & LinkID2 & "']") 'LinkA.xml
                SDeactivationID = xnLinkA.SelectSingleNode("SDeactivation_ID").InnerText
                For Each xnSDeactivation As Xml.XmlNode In xdSDeactivation.SelectNodes("/Root/SDeactivationTable[contains('," & SDeactivationID & ",', concat(',', SDeactivation_ID, ','))]") 'xdSDeactivation.xml
                    Name = xnSDeactivation.SelectSingleNode("SDeactivation").InnerText
                    If utubec = "" Then
                        utubec = Name
                    Else
                        If utubec.Split(",").Contains(Name) = False Then
                            utubec = utubec & "," & Name
                        End If
                    End If
                Next
            Next
            For Each row In dtMaster.Select("LinkAID = " & LinkID2)
                row("SDeactivation") = utubec
            Next
            dtMaster.AcceptChanges()
            utubec = ""
            dtKeyMaster.Rows.Add({rowIndex, LinkAID, fuze_Nsn_id})
            rowIndex += 1
        Next
        Response.Write("Your utubec is : " & utubec)
        Session("dtMaster") = dtMaster
        Session("dtKeyMaster") = dtKeyMaster
        If dtMaster.Rows.Count >= 1 Then
            ViewData(dtKeyMaster.Rows(0)(1), dtKeyMaster.Rows(0)(2))
        End If
    End Function
    Private Sub ViewData(ByVal keyLinkAid As String, ByVal keyNsn As String)
        Dim utubec As String = ""
        For Each row In dtMaster.Select("LinkAID = " & keyLinkAid & " and SDeactivation <> ''")
            utubec = row("SDeactivation")
        Next
        Dim SDeactivation As New DataSet
        SDeactivation.ReadXml(Server.MapPath("~/App_Data/SDeactivation.xml"))
        C1SDeactivation.DataSource = SDeactivation.Tables(0)
        C1SDeactivation.DataTextField = "SDeactivation"
        C1SDeactivation.DataValueField = "SDeactivation_ID"
        C1SDeactivation.DataBind()
        C1SDeactivation.ClearSelection()
        For i As Integer = 0 To C1SDeactivation.Items.Count - 1
            If utubec.Split(",").Contains(C1SDeactivation.Items(i).Text) Then
                C1SDeactivation.Items(i).Selected = True
                Dim CB As CheckBox = C1SDeactivation.Items(i).FindControl("CheckSDeactivation")
                CB.Checked = True
            End If
        Next
        Dim _table As DataView = dtMaster.DefaultView
        _table.RowFilter = "NSN_ID in (" & keyNsn & ")"
        C1NSN.DataSource = _table
        C1NSN.DataTextField = "NSN"
        C1NSN.DataValueField = "NSN_ID"
        C1NSN.DataBind()
    End Sub

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
        dtMaster = Session("dtMaster")
        dtKeyMaster = Session("dtKeyMaster")
        Dim rowId As Integer = Session("currentIndex") + 1
        ViewData(dtKeyMaster.Rows(rowId)(1), dtKeyMaster.Rows(rowId)(2))
    End Sub
    Private Sub loadfile()
        If IsPostBack = False Then
            Dim Fuze As New DataSet
            C1Fuze.Items.Clear()
            Fuze.ReadXml(Server.MapPath("~/App_Data/Fuze.xml"))
            C1Fuze.DataSource = Fuze.Tables(0)
            C1Fuze.DataMember = "Fuze"
            C1Fuze.DataTextField = "Fuze"
            C1Fuze.DataValueField = "Fuze_ID"
            C1Fuze.DataBind()

            Dim SDeactivation As New DataSet
            SDeactivation.ReadXml(Server.MapPath("~/App_Data/SDeactivation.xml"))
            C1SDeactivation.DataSource = SDeactivation.Tables(0)
            C1SDeactivation.DataTextField = "SDeactivation"
            C1SDeactivation.DataValueField = "SDeactivation_ID"
            C1SDeactivation.DataBind()
        End If
    End Sub
End Class
0
 
Rajar AhmedConsultantCommented:
0
 
vcharlesAuthor Commented:
Hi,

I am having problems with loading multiple listboxes using your approach, For example when LinkA includes the country field, how do I load the listbox for country based on LinkIAD linked to LinkAID in linssadb? like  you did it for SDEactivation.

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<Root>
  <LinkA>
    <LinkAID>0</LinkAID>
    <SDeactivation_ID>NA</SDeactivation_ID>
    <Country_ID>NA</Country_ID>
  </LinkA>
  <LinkA>
    <LinkAID>1</LinkAID>
    <SDeactivation_ID>0,1,2</SDeactivation_ID>
     <Country_ID>1,2</Country_ID>
  </LinkA>
  <LinkA>
    <LinkAID>2</LinkAID>
    <SDeactivation_ID>1,2</SDeactivation_ID>
     <Country_ID>1,2</Country_ID>
  </LinkA>
</Root>
0
 
vcharlesAuthor Commented:
Hi,

Looking at Keynsn,values for both records found (1,2 and 3,4)  the problem is it is looking for data in LinkSSADB for country instead of looking for countryID in LinkA. How do I search for matching IDs for country in LinkA instéad of Linkssadb?
Thanks,
Victor
0
 
Rajar AhmedConsultantCommented:
try this,
Imports System.Xml
Imports System
Imports System.Text
Imports C1.Web.UI.Controls.C1ComboBox
Imports C1.Web.UI.Controls.C1Input
Imports System.IO
Imports System.Data
Partial Class WebForm1
    Inherits System.Web.UI.Page
    Public CurrentIndex As Integer
    Dim dtMaster As DataTable
    Dim dtAmmoType As DataTable
    Dim dtKeyMaster As DataTable
    'C1Fuze - is First dropdwn
    'C1NSN - IS first Listbox
    'C1SDeactivation - is second ddl

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        loadfile()
    End Sub

    Protected Sub C1Fuze_SelectedIndexChanged(ByVal sender As Object, ByVal args As C1.Web.UI.Controls.C1ComboBox.C1ComboBoxEventArgs) ' Handles C1Fuze.SelectedIndexChanged
        SearchFuze1()
    End Sub

    Public Function SearchFuze1()
        'Declaration XmlDocuments
        Dim xdLink As New Xml.XmlDocument
        Dim xdLinkA As New Xml.XmlDocument
        Dim xdNSN As New Xml.XmlDocument
        Dim xdCountry As New Xml.XmlDocument

        Dim xdSDeactivation As New Xml.XmlDocument
        ' load XML documents
        xdLink.Load(Server.MapPath("~/App_Data/LinkSSADB.xml"))
        xdLinkA.Load(Server.MapPath("~/App_Data/LinkA.xml"))
        xdNSN.Load(Server.MapPath("~/App_Data/NSN.xml"))
        xdCountry.Load(Server.MapPath("~/App_Data/Country.xml"))
        xdSDeactivation.Load(Server.MapPath("~/App_Data/SDeactivation.xml"))
        'Declare variables
        Dim Name As String
        Dim NSNID As String
        Dim fuze_Nsn_id As String
        Dim LinkAID As String
        Dim SDeactivation_ID As String, SDeactivation As String
        Dim SDeactivationID As String
        Dim NSNID2 As String
        Dim SDeactivationID2 As String
        Dim Link_ID As String, LinkID2 As String
        Dim utubec As String
        dtMaster = New DataTable
        dtMaster.Columns.Add("FUZE_NSN_ID", GetType(String))
        dtMaster.Columns.Add("LinkAID", GetType(String))
        dtMaster.Columns.Add("NSN_ID", GetType(String))
        dtMaster.Columns.Add("NSN", GetType(String))
        dtMaster.Columns.Add("SDeactivation_ID", GetType(String))
        dtMaster.Columns.Add("SDeactivation", GetType(String))
        dtMaster.Columns.Add("Country_ID", GetType(String))
        dtMaster.Columns.Add("Country", GetType(String))
        dtKeyMaster = New DataTable
        dtKeyMaster.Columns.Add("rowId", GetType(String))
        dtKeyMaster.Columns.Add("keyLinkAid", GetType(String))
        dtKeyMaster.Columns.Add("keyNsn", GetType(String))
        dtKeyMaster.Columns.Add("Country_id", GetType(String))
        Dim rowIndex As Integer = 1
        For Each xnLink As Xml.XmlNode In xdLink.SelectNodes("/Root/LinkA[Fuze_ID='" & C1Fuze.SelectedItem.Value & "']") 'linkssadb.xml
            Link_ID = xnLink.SelectSingleNode("LinkAID").InnerText
            NSNID = xnLink.SelectSingleNode("NSN_ID").InnerText
            fuze_Nsn_id = NSNID
            LinkAID = Link_ID
            'List Box Load With matching fuze id in linkssadb.xml - Starts
            For Each xnNSN As Xml.XmlNode In xdNSN.SelectNodes("/Root/NSNTable[contains('," & NSNID & ",', concat(',', NSN_ID, ','))]") 'NSN.xml
                NSNID2 = xnNSN.SelectSingleNode("NSN_ID").InnerText
                If dtMaster.Select("NSN_ID in (" & NSNID2 & ")").Length = 0 Then
                    Name = xnNSN.SelectSingleNode("NSN").InnerText
                    dtMaster.Rows.Add({fuze_Nsn_id, LinkAID, NSNID2, Name})
                End If
            Next



            'List Box Load With matching fuze id in linkssadb.xml - Ends
            LinkID2 = xnLink.SelectSingleNode("LinkAID").InnerText 'linkssadb.xml
            ViewState("currentIndex") = 0
            Dim coutryId As String = ""
            For Each xnLinkA As Xml.XmlNode In xdLinkA.SelectNodes("/Root/LinkA[LinkAID='" & LinkID2 & "']") 'LinkA.xml
                SDeactivationID = xnLinkA.SelectSingleNode("SDeactivation_ID").InnerText
                coutryId = xnLinkA.SelectSingleNode("Country_ID").InnerText
                For Each xnSDeactivation As Xml.XmlNode In xdSDeactivation.SelectNodes("/Root/SDeactivationTable[contains('," & SDeactivationID & ",', concat(',', SDeactivation_ID, ','))]") 'xdSDeactivation.xml
                    Name = xnSDeactivation.SelectSingleNode("SDeactivation").InnerText
                    If utubec = "" Then
                        utubec = Name
                    Else
                        If utubec.Split(",").Contains(Name) = False Then
                            utubec = utubec & "," & Name
                        End If
                    End If
                Next
            Next
            'For Each row In dtMaster.Select("LinkAID = " & LinkID2)
            '    row("SDeactivation") = utubec
            'Next
            ' dtMaster.AcceptChanges()

            For Each row In dtMaster.Select("LinkAID = " & LinkID2)
                row("SDeactivation") = utubec
                row("country_id") = coutryId
            Next
            dtMaster.AcceptChanges()

            utubec = ""
            dtKeyMaster.Rows.Add({rowIndex, LinkAID, fuze_Nsn_id, coutryId})
            rowIndex += 1
        Next
        Response.Write("Your utubec is : " & utubec)
        ViewState("dtMaster") = dtMaster
        ViewState("dtKeyMaster") = dtKeyMaster
        If dtMaster.Rows.Count >= 1 Then
            ViewData(dtKeyMaster.Rows(0)(1), dtKeyMaster.Rows(0)(2), dtKeyMaster.Rows(0)(3))
        End If

    End Function
    Private Sub ViewData(ByVal keyLinkAid As String, ByVal keyNsn As String, ByVal keyCountry_id As String)
        Dim utubec As String = ""
        Dim _table As DataView
        For Each row In dtMaster.Select("LinkAID = " & keyLinkAid & " and SDeactivation <> ''")
            utubec = row("SDeactivation")
        Next
        Dim SDeactivation As New DataSet
        SDeactivation.ReadXml(Server.MapPath("~/App_Data/SDeactivation.xml"))
        C1SDeactivation.DataSource = SDeactivation.Tables(0)
        C1SDeactivation.DataTextField = "SDeactivation"
        C1SDeactivation.DataValueField = "SDeactivation_ID"
        C1SDeactivation.DataBind()
        C1SDeactivation.ClearSelection()
        For i As Integer = 0 To C1SDeactivation.Items.Count - 1
            If utubec.Split(",").Contains(C1SDeactivation.Items(i).Text) Then
                C1SDeactivation.Items(i).Selected = True
                Dim CB As CheckBox = C1SDeactivation.Items(i).FindControl("CheckSDeactivation")
                CB.Checked = True
            End If
        Next
        _table = dtMaster.DefaultView
        _table.RowFilter = "NSN_ID in (" & keyNsn & ")"
        C1NSN.DataSource = _table
        C1NSN.DataTextField = "NSN"
        C1NSN.DataValueField = "NSN_ID"
        C1NSN.DataBind()
        Dim countryXml As New DataSet
        countryXml.ReadXml(Server.MapPath("~/App_Data/Country.xml"))
        _table = countryXml.Tables(0).DefaultView
        _table.RowFilter = "country_id in(" & keyCountry_id & ")"
        C1Country.DataSource = _table
        C1Country.DataTextField = "Country"
        C1Country.DataValueField = "Country_ID"
        C1Country.DataBind()
    End Sub


    Private Sub loadfile()
        If IsPostBack = False Then
            Dim Fuze As New DataSet
            C1Fuze.Items.Clear()
            Fuze.ReadXml(Server.MapPath("~/App_Data/Fuze.xml"))
            C1Fuze.DataSource = Fuze.Tables(0)
            C1Fuze.DataMember = "Fuze"
            C1Fuze.DataTextField = "Fuze"
            C1Fuze.DataValueField = "Fuze_ID"
            C1Fuze.DataBind()

            Dim SDeactivation As New DataSet
            SDeactivation.ReadXml(Server.MapPath("~/App_Data/SDeactivation.xml"))
            C1SDeactivation.DataSource = SDeactivation.Tables(0)
            C1SDeactivation.DataTextField = "SDeactivation"
            C1SDeactivation.DataValueField = "SDeactivation_ID"
            C1SDeactivation.DataBind()

            Dim Country As New DataSet
            Country.ReadXml(Server.MapPath("~/App_Data/Country.xml"))
            C1Country.DataSource = Country.Tables(0)
            C1Country.DataTextField = "Country"
            C1Country.DataValueField = "Country_ID"
            C1Country.DataBind()
        End If
    End Sub
    Protected Sub btnFirst_Click(ByVal sender As Object, ByVal e As EventArgs)
        dtMaster = ViewState("dtMaster")
        dtKeyMaster = ViewState("dtKeyMaster")
        Dim rowId As Integer = 0
        ViewData(dtKeyMaster.Rows(rowId)(1), dtKeyMaster.Rows(rowId)(2), dtKeyMaster.Rows(rowId)(3))
        ViewState("currentIndex") = rowId

    End Sub
    Protected Sub btnPrev_Click(ByVal sender As Object, ByVal e As EventArgs)
        dtMaster = ViewState("dtMaster")
        dtKeyMaster = ViewState("dtKeyMaster")
        Dim rowId As Integer
        If ViewState("currentIndex") >= 1 Then
            rowId = ViewState("currentIndex") - 1
        Else
            rowId = 0
        End If
        ViewData(dtKeyMaster.Rows(rowId)(1), dtKeyMaster.Rows(rowId)(2), dtKeyMaster.Rows(rowId)(3))
        ViewState("currentIndex") = rowId

    End Sub
    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnNext.Click
        dtMaster = ViewState("dtMaster")
        dtKeyMaster = ViewState("dtKeyMaster")
        Dim rowId As Integer = ViewState("currentIndex") + 1
        ViewData(dtKeyMaster.Rows(rowId)(1), dtKeyMaster.Rows(rowId)(2), dtKeyMaster.Rows(rowId)(3))
        ViewState("currentIndex") = rowId

    End Sub
    Protected Sub btnLast_Click(ByVal sender As Object, ByVal e As EventArgs)
        dtMaster = ViewState("dtMaster")
        dtKeyMaster = ViewState("dtKeyMaster")
        Dim rowId As Integer = dtKeyMaster.Rows.Count - 1
        ViewData(dtKeyMaster.Rows(rowId)(1), dtKeyMaster.Rows(rowId)(2), dtKeyMaster.Rows(rowId)(3))
        ViewState("currentIndex") = rowId

    End Sub
End Class

Open in new window

0
 
vcharlesAuthor Commented:
Perfect!! I will follow the same example with the other 10 listbox controls.

Thank You!

Victor
0
 
vcharlesAuthor Commented:
Hi again,

I"m afraid I made a mistake, the country data shoukd be in LinkB.xml not LinkA, just realised that when I tested the actual application. Can the same approach be taken using LinkB, LinkC, LinkD etc.. all linked by LinkAID? If possible, can you please show me an example how to use this approach using LinkB with country.

 For Each xnLinkA As Xml.XmlNode In xdLinkA.SelectNodes("/Root/LinkA[LinkAID='" & LinkID2 & "']") 'LinkA.xml
                SDeactivationID = xnLinkA.SelectSingleNode("SDeactivation_ID").InnerText
                CountryIDa = xnLinkA.SelectSingleNode("Country_ID").InnerText  *****'Error
                For Each xnSDeactivation As Xml.XmlNode In xdSDeactivation.SelectNodes("/Root/SDeactivationTable[contains('," & SDeactivationID & ",', concat(',', SDeactivation_ID, ','))]") 'xdSDeactivation.xml
                    Name = xnSDeactivation.SelectSingleNode("SDeactivation").InnerText
                    If utubec = "" Then
                        utubec = Name
                    Else
                        If utubec.Split(",").Contains(Name) = False Then
                            utubec = utubec & "," & Name
                        End If
                    End If
                Next
            Next
0

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 7
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now