How do I display data in a grid based on multiple ID values in my link.xml file.

vcharles
vcharles used Ask the Experts™
on
Hello,

How do I display data in a grid based on multiple ID values in my link.xml file.

For example I have two xml files with the following data

1. CountryUser.xml

<CountryUserUserTable>
<CountryUserUser_ID>1</CountryUserUser_ID>
<CountryUserUser>BEL</CountryUserUser>
</CountryUserUserTable>

<CountryUserUserTable>
<CountryUserUser_ID>2</CountryUserUser_ID>
<CountryUserUser>CAN</CountryUserUser>
</CountryUserUserTable>


<CountryUserUserTable>
<CountryUserUser_ID>3</CountryUserUser_ID>
<CountryUserUser>DEU</CountryUserUser>
</CountryUserUserTable>

<CountryUserUserTable>
<CountryUserUser_ID>4</CountryUserUser_ID>
<CountryUserUser>FRA</CountryUserUser>
</CountryUserUserTable>

2. Link.xml

<LinkTable>
<LinkAID>1</LinkAID>
<CountryUserUser_ID>1,2,4</CountryUserUser_ID>
</CountryUserUserTable>

Based on the values of CountryUser_ID in my link.xml file How do I display

BEL
CAN
FRA

on my Grid?

I am able to do display the values in a Textbox with only one ID value in my Link.xml file (i.e. <CountryUserUser_ID>1</CountryUserUser_ID>)  with the code below, but need help displaying the data in GridView when I have multiple ID values.

Code for single value:

 For Each xnLink As Xml.XmlNode In xdLink.SelectNodes("/Root/LinkA[Country_ID='" & C1Country.SelectedItem.Value & "']")
 Link_ID = xnLink.SelectSingleNode("LinkAID").InnerText
 ReceiverID = xnLink.SelectSingleNode("CountryUser_ID").InnerText

  For Each xnReceiver As Xml.XmlNode In xdReceiver.SelectNodes("/Root/CountryUserTable[CountryUser_ID='" & ReceiverID & "']")
  ReceiverID2 = xnReceiver.SelectSingleNode("CountryUser_ID").InnerText
  Name = xnReceiver.SelectSingleNode("CountryUser").InnerText
  dtReceiver.Rows.Add({ReceiverID2, Name})
  Next
  C1CountryUser.Text = dtReceiver.Rows(CurrentIndex).Item("CountryUser")


Below is also the code I used to pass data separated by (;) to multiple rows in my GridView, can it be modified to accomplish what I am trying to do? instead of the variale s, for example, I need to some how get ReceiverID2 to read the CountryUser_ID wich contains 1,2,4.

            Dim s as string
            s = "1.;2.;3.;4.;5."
            Dim tmp() As String = s.Split(";")
            Dim dTable As New DataTable
            dTable.Columns.Add("Column1", GetType(String))
            For i As Integer = 0 To tmp.Length - 1
                dTable.Rows.Add(New Object() {tmp(i)})
            Next
            GridView1.DataSource = dTable
            GridView1.DataBind()
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Robert SchuttSoftware Engineer

Commented:
I think you're looking for something like this.

Note: There are some inconsistencies between the xml examples and the code. I have changed the code (argument to selectNodes) but possibly it needs to be the other way around?

            Dim xdlink As New Xml.XmlDocument, xdReceiver As New Xml.XmlDocument, Link_ID As String, ReceiverID As String, ReceiverID2 As String, Name As String
            xdlink.Load(Server.MapPath("Link.xml"))
            xdReceiver.Load(Server.MapPath("CountryUser.xml"))
            For Each xnLink As Xml.XmlNode In xdlink.SelectNodes("/Root/LinkTable") ' LinkA[Country_ID='...'] ?
                Link_ID = xnLink.SelectSingleNode("LinkAID").InnerText
                ReceiverID = xnLink.SelectSingleNode("CountryUserUser_ID").InnerText ' CountryUser_ID
                Dim tmp() As String = ReceiverID.Split(",")
                Dim selectionString As String = ""
                For i As Integer = 0 To tmp.Length - 1
                    If selectionString <> "" Then selectionString &= " or "
                    selectionString &= "CountryUserUser_ID='" & tmp(i) & "'"
                Next

                For Each xnReceiver As Xml.XmlNode In xdReceiver.SelectNodes("/Root/CountryUserUserTable[" & selectionString & "]")
                    ReceiverID2 = xnReceiver.SelectSingleNode("CountryUserUser_ID").InnerText
                    Name = xnReceiver.SelectSingleNode("CountryUserUser").InnerText
                    dtReceiver.Rows.Add({ReceiverID2, Name})
                Next
            Next
            GridView1.DataSource = dtReceiver
            GridView1.DataBind()

Open in new window

Author

Commented:
Hi,

Thanks for the code, made some modifications but I'm getting error message:

"Object reference not set to an instance of an object"

On line:
dtReceiver.Rows.Add({ReceiverID2, Name})

Below is an example of my xml files and the latest code, can you please take a look to see what is causing this error.

Thanks.

LinkSSADB.xml

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<Root>
  <LinkA>
    <LinkAID>1</LinkAID>
    <CountryUser_ID>1,2,3</CountryUser_ID>
  </LinkA>
  <LinkA>
    <LinkAID>2</LinkAID>
    <CountryUser_ID>1,2,3,4</CountryUser_ID>
  </LinkA>
  <LinkA>
    <LinkAID>3</LinkAID>
    <CountryUser_ID>2,3,4</CountryUser_ID>
  </LinkA>
</Root>

CountryUser.xml:
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<Root>
  <CountryUserTable>
    <CountryUser_ID>1</CountryUser_ID>
    <CountryUser>BEL</CountryUser>
  </CountryUserTable>
  <CountryUserTable>
    <CountryUser_ID>2</CountryUser_ID>
    <CountryUser>CAN</CountryUser>
  </CountryUserTable>
  <CountryUserTable>
    <CountryUser_ID>3</CountryUser_ID>
    <CountryUser>CZE</CountryUser>
  </CountryUserTable>
  <CountryUserTable>
    <CountryUser_ID>4</CountryUser_ID>
    <CountryUser>DNK</CountryUser>
  </CountryUserTable>
  <CountryUserTable>
    <CountryUser_ID>5</CountryUser_ID>
    <CountryUser>FRA</CountryUser>
  </CountryUserTable>
  <CountryUserTable>
    <CountryUser_ID>6</CountryUser_ID>
    <CountryUser>DEU</CountryUser>
  </CountryUserTable>
</Root>


Code:

Dim xdlink As New Xml.XmlDocument, xdReceiver As New Xml.XmlDocument, Link_ID As String, ReceiverID As String, ReceiverID2 As String, Name As String
        xdlink.Load(Server.MapPath("LinkSSADB.xml"))
        xdReceiver.Load(Server.MapPath("CountryUser.xml"))
        For Each xnLink As Xml.XmlNode In xdlink.SelectNodes("/Root/LinkA") ' LinkA[Country_ID='...'] ?
            Link_ID = xnLink.SelectSingleNode("LinkAID").InnerText
            ReceiverID = xnLink.SelectSingleNode("CountryUser_ID").InnerText ' CountryUser_ID
            Dim tmp() As String = ReceiverID.Split(",")
            Dim selectionString As String = ""
            For i As Integer = 0 To tmp.Length - 1
                If selectionString <> "" Then selectionString &= " or "
                selectionString &= "CountryUser_ID='" & tmp(i) & "'"
            Next

            For Each xnReceiver As Xml.XmlNode In xdReceiver.SelectNodes("/Root/CountryUserTable[" & selectionString & "]")
                ReceiverID2 = xnReceiver.SelectSingleNode("CountryUser_ID").InnerText
                Name = xnReceiver.SelectSingleNode("CountryUser").InnerText
                dtReceiver.Rows.Add({ReceiverID2, Name})  *****Error Line

Author

Commented:
I will only need to access one record at a time, for example for the first record in LinkSSADB.xml, my Grid should display.
BEL
CAN
CZE.

Victor
Robert SchuttSoftware Engineer

Commented:
O sorry I thought you would have the dtReceiver available already.

    Dim dtReceiver As New DataTable
    dtReceiver.Columns.Add(New DataColumn("ID"))
    dtReceiver.Columns.Add(New DataColumn("Name"))

Open in new window


To select 1 country you can restore your previous selection (in the first SelectNodes) that I deleted because I didn't know where it was coming from:

For Each xnLink As Xml.XmlNode In xdLink.SelectNodes("/Root/LinkA[Country_ID='" & C1Country.SelectedItem.Value & "']")

Open in new window

Robert SchuttSoftware Engineer

Commented:
No, copied the wrong one for that last part, use:

For Each xnLink As Xml.XmlNode In xdLink.SelectNodes("/Root/LinkA[Country_ID='" & C1Country.SelectedItem.Value & "']")

Open in new window


It uses the other names now in the xml.

Author

Commented:
Thanks, How do you modify the code to search for an ID that is part of the string?

For example my CountryUser_ID in my Link has multiple values (1,2,3)

 For Each xnLink As Xml.XmlNode In xdlink.SelectNodes("/Root/LinkA[CountryUser_ID='" & C1CountryOrigin.SelectedItem.Value & "']")
Robert SchuttSoftware Engineer

Commented:
Oops, still the wrong code. My bad!

First we look for the selected country so that line looks for 1 specific ID but I used the wrong element name. It should be:

For Each xnLink As Xml.XmlNode In xdLink.SelectNodes("/Root/LinkA[LinkAID='" & C1Country.SelectedItem.Value & "']")

In the second part a selection string is built to select more than 1 country using basically your own 'split' routine.

Author

Commented:
Hi,

Thanks for the code, but I will be searching  LinkSSADB  by CountryUser_ID not by LinkAID, for example when the user selects BEL and its ID is 1, I need to search for 1 in the CountryUser_ID element.

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<Root>
  <LinkA>
    <LinkAID>1</LinkAID>
    <CountryUser_ID>1,2,3</CountryUser_ID>
  </LinkA>
  <LinkA>
    <LinkAID>2</LinkAID>
    <CountryUser_ID>1,2,3,4</CountryUser_ID>
  </LinkA>
  <LinkA>
    <LinkAID>3</LinkAID>
    <CountryUser_ID>2,3,4</CountryUser_ID>
  </LinkA>
</Root>
Robert SchuttSoftware Engineer

Commented:
That's possible but contradictory to both your earlier examples.

If you search for '1' in CountryUser_ID you find corresponding LinkAID's 1 and 2, but not 3. So would these 'point back' to the same records in LinkSSADB? That would be only BEL and CAN.

By the way, is the xml definition your own? Maybe it's easier if you could use:

<Root>
  <LinkA>
    <LinkAID>1</LinkAID>
    <CountryUser_ID>1</CountryUser_ID>
    <CountryUser_ID>2</CountryUser_ID>
    <CountryUser_ID>3</CountryUser_ID>
  </LinkA>
...

Open in new window

Author

Commented:
Hi,

I need to keep the existing format, only showed you part of the linkSSADB.xml, it has about 10 elements, but I am only focusing on the CountryUser_ID, will need to apply the same approach for the other elements.

If I search for CountryUer_ID = 1 in my LinkSSADB.xml file it should rectreive records wherever 1 is found in the CountryUser_ID of my LinkSSADB file.

For example if the LinkSSADB contains the following

<CountryUser_ID>1,2,4</CountryUser_ID>
<CountryUser_ID>2,4</CountryUser_ID>
<CountryUser_ID>1,2,5</CountryUser_ID>
<CountryUser_ID>1,6</CountryUser_ID>

My Grid should show me:

BEL
CAN
DNK

When I click on the Next record I should see

BEL
CAN
FRA

When I click on the Next record I should see

BEL
DEU

CountryUser.xml:
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<Root>
  <CountryUserTable>
    <CountryUser_ID>1</CountryUser_ID>
    <CountryUser>BEL</CountryUser>
  </CountryUserTable>
  <CountryUserTable>
    <CountryUser_ID>2</CountryUser_ID>
    <CountryUser>CAN</CountryUser>
  </CountryUserTable>
  <CountryUserTable>
    <CountryUser_ID>3</CountryUser_ID>
    <CountryUser>CZE</CountryUser>
  </CountryUserTable>
  <CountryUserTable>
    <CountryUser_ID>4</CountryUser_ID>
    <CountryUser>DNK</CountryUser>
  </CountryUserTable>
  <CountryUserTable>
    <CountryUser_ID>5</CountryUser_ID>
    <CountryUser>FRA</CountryUser>
  </CountryUserTable>
  <CountryUserTable>
    <CountryUser_ID>6</CountryUser_ID>
    <CountryUser>DEU</CountryUser>
  </CountryUserTable>
</Root>
Robert SchuttSoftware Engineer

Commented:
The code without changing the xml would be:

    Private Sub UpdateGrid()
        If C1CountryOrigin.SelectedItem IsNot Nothing Then
            Dim dtReceiver As New DataTable
            dtReceiver.Columns.Add(New DataColumn("ID"))
            dtReceiver.Columns.Add(New DataColumn("Name"))
            Dim xdlink As New Xml.XmlDocument, xdReceiver As New Xml.XmlDocument, Link_ID As String, ReceiverID As String, ReceiverID2 As String, Name As String
            xdlink.Load(Server.MapPath("LinkSSADB.xml"))
            xdReceiver.Load(Server.MapPath("CountryUser.xml"))
            Dim selectionString As String = ""
            For Each xnLink As Xml.XmlNode In xdlink.SelectNodes("/Root/LinkA")
                Link_ID = xnLink.SelectSingleNode("LinkAID").InnerText
                ReceiverID = xnLink.SelectSingleNode("CountryUser_ID").InnerText
                Dim tmp() As String = ReceiverID.Split(",")
                For i As Integer = 0 To tmp.Length - 1
                    If tmp(i).Equals(C1CountryOrigin.SelectedItem.Value) Then
                        Dim selectionStringNew As String = "CountryUser_ID='" & Link_ID & "'"
                        If Not selectionString.Contains(selectionStringNew) Then ' avoid duplicates, although it wouldn't make a difference really
                            If selectionString <> "" Then selectionString &= " or "
                            selectionString &= selectionStringNew
                        End If
                    End If
                Next
            Next
            If Not String.IsNullOrEmpty(selectionString) Then
                For Each xnReceiver As Xml.XmlNode In xdReceiver.SelectNodes("/Root/CountryUserTable[" & selectionString & "]")
                    ReceiverID2 = xnReceiver.SelectSingleNode("CountryUser_ID").InnerText
                    Name = xnReceiver.SelectSingleNode("CountryUser").InnerText
                    dtReceiver.Rows.Add({ReceiverID2, Name})
                Next
            End If
            GridView1.DataSource = dtReceiver
            GridView1.DataBind()
        End If
    End Sub

Open in new window

Robert SchuttSoftware Engineer

Commented:
Ok, I'm afraid I still misunderstood you (I posted my previous post around the same time as yours so I hadn't seen that yet).

Let me re-read it and I will change the code.

Author

Commented:
Ok, I appreciate your Help.
Robert SchuttSoftware Engineer

Commented:
I think there's one piece missing from your previous post. You give 4 lines but only three example outputs, it looks like you skipped: When you select the second record with countries 2,4 you expect: CAN, DNK?

Author

Commented:
Since that record does not include 1, it should not show.
Robert SchuttSoftware Engineer

Commented:
Ah, so this is still all with a selection of "1". I understood 'click on the Next record' as changing the selection.

How about this:

            Dim dtReceiver As New DataTable
            dtReceiver.Columns.Add(New DataColumn("ID"))
            dtReceiver.Columns.Add(New DataColumn("Name"))
            Dim xdlink As New Xml.XmlDocument, xdReceiver As New Xml.XmlDocument, Link_ID As String, ReceiverID As String, ReceiverID2 As String, Name As String
            xdlink.Load(Server.MapPath("LinkSSADB.xml"))
            xdReceiver.Load(Server.MapPath("CountryUser.xml"))
            For Each xnLink As Xml.XmlNode In xdlink.SelectNodes("/Root/LinkA") ' [LinkAID='" & C1CountryOrigin.SelectedItem.Value & "']
                Link_ID = xnLink.SelectSingleNode("LinkAID").InnerText
                ReceiverID = xnLink.SelectSingleNode("CountryUser_ID").InnerText
                Dim tmp() As String = ReceiverID.Split(",")
                Dim selectionString As String = ""
                If tmp.Contains(C1CountryOrigin.SelectedItem.Value) Then
                    For i As Integer = 0 To tmp.Length - 1
                        Dim selectionStringNew As String = "CountryUser_ID='" & tmp(i) & "'"
                        If Not selectionString.Contains(selectionStringNew) Then ' avoid duplicates, although it wouldn't make a difference really
                            If selectionString <> "" Then selectionString &= " or "
                            selectionString &= selectionStringNew
                        End If
                    Next
                    Name = ""
                    If Not String.IsNullOrEmpty(selectionString) Then
                        For Each xnReceiver As Xml.XmlNode In xdReceiver.SelectNodes("/Root/CountryUserTable[" & selectionString & "]")
                            ReceiverID2 = xnReceiver.SelectSingleNode("CountryUser_ID").InnerText
                            If Name <> "" Then Name &= ", "
                            Name &= xnReceiver.SelectSingleNode("CountryUser").InnerText
                        Next
                    End If
                    dtReceiver.Rows.Add({ReceiverID, Name})
                End If
            Next
            GridView1.DataSource = dtReceiver
            GridView1.DataBind()

Open in new window

Author

Commented:
Hi,

I am making great progress..Thanks.

Is there a way to only see one record at time on the Grid? For example if my query for CountryOrigin finds 2 records, I only want to see one record at a time. Right now, results for all records found are showing on the grid at the same time.  

As mentioned my LinkSSADB contains 9 different data elements to be displayed in 9 Grid controls. However once I grasp the same concept can be applied for the remaing 8 Grids.

Example of 3 records in LinkSSADB:

<LinkA>
<LinkAID>1</LinkAID>1
<CountryUser_ID>1,2,3,4</CountryUser_ID>
<CountryOrigin_ID>5,4</CountryOrigin_ID>
<ItemA_ID>11,23,8</ItemA_ID>
<ItemA_ID>7</ItemA_ID>
<ItemA_ID>8,9,11</ItemA_ID>
<ItemA_ID>7,12,34</ItemA_ID>
<ItemA_ID>8,6,4</ItemA_ID>
<ItemA_ID>3</ItemA_ID>
<ItemA_ID>8,3,9,5,4</ItemA_ID>
</LinkA>
<LinkA>
<LinkAID>2</LinkAID>1
<CountryUser_ID>7,9,3</CountryUser_ID>
<CountryOrigin_ID>4,3,2</CountryOrigin_ID>
<ItemA_ID>11,8</ItemA_ID>
<ItemA_ID>7,7,33,8</ItemA_ID>
<ItemA_ID>18,9,11</ItemA_ID>
<ItemA_ID>17,112,314</ItemA_ID>
<ItemA_ID>8,16,41</ItemA_ID>
<ItemA_ID>3</ItemA_ID>
<ItemA_ID>8,13,9,15,4</ItemA_ID>
</LinkA>
<LinkA>
<LinkAID>3</LinkAID>1
<CountryUser_ID>12,22,</CountryUser_ID>
<CountryOrigin_ID>6,5,4</CountryOrigin_ID>
<ItemA_ID>111,23,18</ItemA_ID>
<ItemA_ID>7</ItemA_ID>
<ItemA_ID>8,19,11</ItemA_ID>
<ItemA_ID>17,12,34</ItemA_ID>
<ItemA_ID>8,16,41</ItemA_ID>
<ItemA_ID>7,2</ItemA_ID>
<ItemA_ID>8,31,9,15,4</ItemA_ID>
</LinkA>

If my search is for CountryOrigin = 5, than I would need to display all the records from  LinkAID = 1 and LinkAID = 3. How I would show all the data elements for LinkAID = 1 than when I press the Next button, how do to show all the data elements for LinkAID = 3.

Thanks.

Author

Commented:
Hi,

This is the code I am using to Move to the Next record, but it was for when I only had one ID value in my LinkSSADB file.

dtTable = Session("dtTable")
dtDonor = Session("dtDonor")
dtReceiver = Session("dtReceiver")
CurrentIndex = Session("CurrentIndex")
LinkID2 = Session("LinkID2")
If CurrentIndex < dtTable.Rows.Count - 1 Then
CurrentIndex += 1
Session("CurrentIndex") = CurrentIndex
C1CountryOrigin.Text = dtDonor.Rows(CurrentIndex).Item("CountryOrigin")
C1CountryUser.Text = dtReceiver.Rows(CurrentIndex).Item("CountryUser")
If CurrentIndex = dtTable.Rows.Count Then
 ButtonNext.Enabled = False
 End If
 Label8.Text = CurrentIndex + 1
 Label6.Text = dtTable.Rows.Count

Author

Commented:
Hi,

Below is an example of the code used when I only had one ID value in the data element of my LinkSSADB file. Perhaps it will help you better understand what I'm trying to do, and how to modify it when I have multiple IDs in my data elements.

Thanks.

Code:

Dim xdLink As New Xml.XmlDocument
Dim xdLinkA As New Xml.XmlDocument
Dim xdDonor As New Xml.XmlDocument
Dim xdReceiver As New Xml.XmlDocument
Dim xdManufacturer As New Xml.XmlDocument


xdLink.Load(Server.MapPath("~/App_Data/LinkSSADB.xml"))
xdLinkA.Load(Server.MapPath("~/App_Data/LinkA.xml"))
xdDonor.Load(Server.MapPath("~/App_Data/CountryOrigin.xml"))
xdReceiver.Load(Server.MapPath("~/App_Data/CountryUser.xml"))
xdManufacturer.Load(Server.MapPath("~/App_Data/Manufacturer.xml"))


Dim Name As String
Dim DonorID As String
Dim ReceiverID As String
Dim DonorID2 As String
Dim ReceiverID2 As String
Dim ManufacturerID As String
Dim ManufacturerID2 As String


dtReceiver = New DataTable
dtReceiver.Columns.Add("CountryUser_ID", GetType(String))
dtReceiver.Columns.Add("CountryUser", GetType(String))

dtDonor = New DataTable
dtDonor.Columns.Add("CountryOrigin_ID", GetType(String))
dtDonor.Columns.Add("CountryOrigin", GetType(String))


dtManufacturer = New DataTable
dtManufacturer.Columns.Add("Manufacturer_ID", GetType(String))
dtManufacturer.Columns.Add("Manufacturer", GetType(String))



Session("dtTable") = dtTable
Session("dtDonor") = dtDonor
Session("dtReceiver") = dtReceiver
Session("dtManufacturer") = dtManufacturer


For Each xnLink As Xml.XmlNode In xdLink.SelectNodes("/Root/LinkA[ItemA_ID='" & ItemA.SelectedItem.Value & "']")

Link_ID = xnLink.SelectSingleNode("LinkAID").InnerText
ReceiverID = xnLink.SelectSingleNode("CountryUser_ID").InnerText
DonorID = xnLink.SelectSingleNode("CountryOrigin_ID").InnerText


For Each xnDonor As Xml.XmlNode In xdDonor.SelectNodes("/Root/CountryOriginTable[CountryOrigin_ID='" & DonorID & "']")
DonorID2 = xnDonor.SelectSingleNode("CountryOrigin_ID").InnerText
Name = xnDonor.SelectSingleNode("CountryOrigin").InnerText
dtDonor.Rows.Add({DonorID2, Name})
Next

For Each xnReceiver As Xml.XmlNode In xdReceiver.SelectNodes("/Root/CountryUserTable[CountryUser_ID='" & ReceiverID & "']")
ReceiverID2 = xnReceiver.SelectSingleNode("CountryUser_ID").InnerText
Name = xnReceiver.SelectSingleNode("CountryUser").InnerText
dtReceiver.Rows.Add({ReceiverID2, Name})
Next

LinkID2 = xnLink.SelectSingleNode("LinkAID").InnerText
dtTable.Rows.Add({LinkID2})


For Each xnLinkA As Xml.XmlNode In xdLinkA.SelectNodes("/Root/LinkA[LinkAID='" & LinkID2 & "']")
ManufacturerID = xnLinkA.SelectSingleNode("Manufacturer_ID").InnerText

For Each xnManufacturer As Xml.XmlNode In xdManufacturer.SelectNodes("/Root/ManufacturerTable[Manufacturer_ID='" & ManufacturerID & "']")
ManufacturerID2 = xnManufacturer.SelectSingleNode("Manufacturer_ID").InnerText
Name = xnManufacturer.SelectSingleNode("Manufacturer").InnerText
dtManufacturer.Rows.Add({ManufacturerID2, Name})
Next

C1CountryOrigin.DataSource = dtDonor
C1CountryOrigin.DataTextField = "CountryOrigin"
C1CountryOrigin.DataValueField = "CountryOrigin_ID"
C1CountryOrigin.DataBind()
C1CountryOrigin.Text = dtDonor.Rows(CurrentIndex).Item("CountryOrigin")


C1CountryUser.DataSource = dtReceiver
C1CountryUser.DataTextField = "CountryUser"
C1CountryUser.DataValueField = "CountryUser_ID"
C1CountryUser.DataBind()

C1Manufacturer.Text = dtManufacturer.Rows(0).Item("Manufacturer")
C1Manufacturer.ToolTip = dtManufacturer.Rows(0).Item("Manufacturer")
C1Manufacturer.Attributes.Add("originaltext", dtManufacturer.Rows(0).Item("Manufacturer"))
Robert SchuttSoftware Engineer

Commented:
Hi, I was out for a bit but I'm back now, need some time to eat and process your info though.

Author

Commented:
Thanks for letting me know, I think we may only need to modify the code for the Grid to initially only show data from the first row of the table.

GridView1.DataSource = dtReceiver.row(0) ' didn't work
GridView1.DataBind()

Then include move code in btnNext and btnPrev to display data from didderent rows.

When showing the data in the Grid, is there a way to remove the commas? For example the data shows as follows:

BEL,
CAN,
DEU,

Author

Commented:
Perhaps there's a way to integrate your code with the code from my previuous post. For example:

For Each xnLink As Xml.XmlNode In xdLink.SelectNodes("/Root/LinkA[ItemA_ID='" & ItemA.SelectedItem.Value & "']")
DonorID = xnLink.SelectSingleNode("CountryOrigin_ID").InnerText
For Each xnDonor As Xml.XmlNode In xdDonor.SelectNodes("/Root/CountryOriginTable[CountryOrigin_ID='" & DonorID & "']")

DonorID2 = xnDonor.SelectSingleNode("CountryOrigin_ID").InnerText
Name = xnDonor.SelectSingleNode("CountryOrigin").InnerText
dtDonor.Rows.Add({DonorID2, Name})
Next

DonorID is only value (1) taking from LinkSSADB.xml (DonorID = xnLink.SelectSingleNode("CountryOrigin_ID").InnerText), but when I have multiple IDs in LinkSSADB.xml, i would need to create dtDonor from DonorID (1,2,5.7) instead of just (1).

I'm happy with your code, just need figure out how to only show one record at a time on the Gridview, but thought I would try to show you my existing code and perhaps there's a way to integrate you code with it, where I have controls with nultiple rows of data.
Robert SchuttSoftware Engineer

Commented:
Yeah, I think that should be possible. Moving through the results can be done in a number of ways. For example by remembering a counter that holds which one is being displayed and re-querying the data each time. It can be done in other ways but this seems the easiest to implement so you can see if that is how you want it.

So I've put a hidden field in the form on the page, called CurrentRecord. It looks like this:

<asp:HiddenField ID="CurrentRecord" runat="server" ViewStateMode="Enabled" />

Open in new window


Here is the code:

    Protected Sub C1Country_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles C1CountryOrigin.SelectedIndexChanged
        ViewState("CurrentRecord") = 1
        UpdateGrid()
    End Sub

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
        ViewState("CurrentRecord") -= 1
        UpdateGrid()
    End Sub

    Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click
        ViewState("CurrentRecord") += 1
        UpdateGrid()
    End Sub

    Private Sub UpdateGrid()
        If C1CountryOrigin.SelectedItem IsNot Nothing Then
            Dim dtReceiver As New DataTable
            dtReceiver.Columns.Add(New DataColumn("ID"))
            dtReceiver.Columns.Add(New DataColumn("Name"))
            Dim xdlink As New Xml.XmlDocument, xdReceiver As New Xml.XmlDocument, Link_ID As String, ReceiverID As String, ReceiverID2 As String, Name As String
            xdlink.Load(Server.MapPath("LinkSSADB.xml"))
            xdReceiver.Load(Server.MapPath("CountryUser.xml"))
            Dim iCount As Integer = 0
            Button1.Enabled = False
            Button2.Enabled = False
            For Each xnLink As Xml.XmlNode In xdlink.SelectNodes("/Root/LinkA") ' [LinkAID='" & C1CountryOrigin.SelectedItem.Value & "']
                Link_ID = xnLink.SelectSingleNode("LinkAID").InnerText
                ReceiverID = xnLink.SelectSingleNode("CountryUser_ID").InnerText
                Dim tmp() As String = ReceiverID.Split(",")
                Dim selectionString As String = ""
                If tmp.Contains(C1CountryOrigin.SelectedItem.Value) Then
                    iCount += 1
                    If iCount < ViewState("CurrentRecord") Then
                        Button1.Enabled = True
                    ElseIf iCount > ViewState("CurrentRecord") Then
                        Button2.Enabled = True
                    Else
                        For i As Integer = 0 To tmp.Length - 1
                            Dim selectionStringNew As String = "CountryUser_ID='" & tmp(i) & "'"
                            If Not selectionString.Contains(selectionStringNew) Then ' avoid duplicates, although it wouldn't make a difference really
                                If selectionString <> "" Then selectionString &= " or "
                                selectionString &= selectionStringNew
                            End If
                        Next
                        Name = ""
                        For Each xnReceiver As Xml.XmlNode In xdReceiver.SelectNodes("/Root/CountryUserTable[" & selectionString & "]")
                            ReceiverID2 = xnReceiver.SelectSingleNode("CountryUser_ID").InnerText
                            Name = xnReceiver.SelectSingleNode("CountryUser").InnerText
                            dtReceiver.Rows.Add({ReceiverID2, Name})
                        Next
                    End If
                End If
            Next
            GridView1.DataSource = dtReceiver
            GridView1.DataBind()
        End If
    End Sub

Open in new window

Robert SchuttSoftware Engineer

Commented:
Oops, again I was busy on a post too long and didn't see your new post until after I put my previous message.
Robert SchuttSoftware Engineer

Commented:
> If my search is for CountryOrigin = 5...

Can you explain a bit about how your search parameters are going to be established, is it possible to choose several criteria or do users first choose which field to search on and then select from that range which of the values to search only within that one field?

Author

Commented:
Hi,

The users will search the LinkSSADB file by one ore more data elements, for example

CountryUser_ID IN (1,2,4) and CountryOrigin_ID in (5,6) and manufacturer_ID IN (6)


and LinkSSADB.xml might look as follows

<CountryUser_ID> 2,3,4</CountryUser_ID>
<CountryOrigin_ID> 5</CountryOrigin_ID>
<Manufacturer_ID> 1,4,6</Manufacturer_ID>

Author

Commented:
I will try your code in the office tomorrow ad get back to you. Thanks.

Author

Commented:
Hi,

I will try your code in couple of hours. How do i modify my search For Each command below to search using multiple data elements?

For Each xnLink As Xml.XmlNode In xdlink.SelectNodes("/Root/LinkA") '

For example:

For Each xnLink As Xml.XmlNode In xdlink.SelectNodes (CountryUser_ID IN (x) and CountryOrigin_ID in (y) and manufacturer_ID IN (z))


Where x,y,z contains multiple IDs (i.e 1,2,3)

Victor

Author

Commented:
Hi,

Below is an example of what I did for a windows application,In part A, I am using one Grid to select multiple values for Manufacturer, receiver and Donor and I am passing the string variables (xyzz) to Part B to display the results in a grid. Can I do something using a web's GridView?


Part A:
Private Sub C1TrueDBGrid3_RowColChange(ByVal sender As Object, ByVal e As C1.Win.C1TrueDBGrid.RowColChangeEventArgs) Handles C1TrueDBGrid3.RowColChange
        Button1.Enabled = True
        Dim Srow1 As Integer
        Dim vc12 As Integer
        If ch = 1 Then
            For Each Srow1 In Me.C1TrueDBGrid3.SelectedRows
                If vc12 > 0 Then
                    xyzz = xyzz & "," & "'" & Me.C1TrueDBGrid3.Columns(1).CellText(Srow1) & "'"
                Else
                    xyzz = "'" & Me.C1TrueDBGrid3.Columns(1).CellText(Srow1) & "'"
                End If
                vc12 = vc12 + 1
            Next
            TextBox1.Text = xyzz
        End If
        If ch = 2 Then
            For Each Srow1 In Me.C1TrueDBGrid3.SelectedRows
                If vc12 > 0 Then
                    xyzz = xyzz & "," & "'" & Me.C1TrueDBGrid3.Columns(1).CellText(Srow1) & "'"
                Else
                    xyzz = "'" & Me.C1TrueDBGrid3.Columns(1).CellText(Srow1) & "'"
                End If
                vc12 = vc12 + 1
            Next
            TextBox2.Text = xyzz
        End If
        If ch = 3 Then
            For Each Srow1 In Me.C1TrueDBGrid3.SelectedRows
                If vc12 > 0 Then
                    xyzz = xyzz & "," & "'" & Me.C1TrueDBGrid3.Columns(1).CellText(Srow1) & "'"
                Else
                    xyzz = "'" & Me.C1TrueDBGrid3.Columns(1).CellText(Srow1) & "'"
                End If
                vc12 = vc12 + 1
            Next
            TextBox3.Text = xyzz
        End If  

End Sub




Part B:

Dim SearchCriteria As String = "Link_ID <> -1"
        If TextBox1.Text <> "" Then
            SearchCriteria &= " AND Manufacturer IN (" & TextBox1.Text & " )"
        End If
       
        If Not (TextBox2.Text = String.Empty) Then
            If astrixState = 0 Then
                SearchCriteria &= " AND Donor  IN (" & TextBox2.Text & " )"
            End If
 
            If astrixState = 1 Then
                SearchCriteria &= " AND Donor  NOT IN (" & TextBox2.Text & ")"
            End If
        End If
 
     If Not (TextBox3.Text = String.Empty) Then
            If astrixState = 0 Then
                SearchCriteria &= " AND Receiver  IN (" & TextBox3.Text & " )"
            End If
            If astrixState = 1 Then
                SearchCriteria &= " AND Receiver NOT IN (" & TextBox3.Text & ")"
            End If
        End If
     
         Dim dt As New DataTable()
        dt.Columns.Add("Link_ID")
        dt.Columns.Add("Manufacturer")
        dt.Columns.Add("Receiver")
        dt.Columns.Add("Donor")

      Dim linker As XElement = XElement.Load(Application.StartupPath + "\LinkFinal.xml")

Dim Manufacturer As XElement = XElement.Load(Application.StartupPath + "\Manufacturer.xml")
       
        Dim Receiver As XElement = XElement.Load(Application.StartupPath + "\Receiver.xml")
        Dim Donor As XElement = XElement.Load(Application.StartupPath + "\Receiver.xml") 'Add (2)

For Each item As XElement In linker.Elements("Row")
            Dim linkID As String = item.Element("Link_ID").Value
            Dim ManufacturerId As String = item.Element
            ("Manufacturer_ID").Value
            Dim receiverId As String = item.Element("Receiver_ID").Value
            Dim DonorID As String = item.Element("Donor_ID").Value 'Add (3)


Dim ManufacturerVal As String = String.Empty
            Dim xe As XElement = Manufacturer.Elements("Row").Cast(Of XElement)().Where(Function(n) n.Element("Manufacturer _ID").Value = ManufacturerId).FirstOrDefault()
            If xe IsNot Nothing Then
                ManufacturerVal = xe.Element("Manufacturer").Value
            End If

            Dim ReceiverVal As String = String.Empty
            xe = Receiver.Elements("Row").Cast(Of XElement)().Where(Function(n) n.Element("Receiver_ID").Value = receiverId).FirstOrDefault()
            If xe IsNot Nothing Then
                receiverVal = xe.Element("Receiver").Value
            End If

            Dim DonorVal As String = String.Empty 'Add (4)
            xe = Donor.Elements("Row").Cast(Of XElement)().Where(Function(n) n.Element("Receiver_ID").Value = DonorID).FirstOrDefault()
            If xe IsNot Nothing Then
                DonorVal = xe.Element("Receiver").Value
            End If

  Dim dr As DataRow = dt.NewRow()
            dr("Link_ID") = linkID        
            dr("Manufacturer") = ManufacturerVal 'Add (5)
            dr("Receiver") = ReceiverVal
            dr("Donor") = DonorVal 'Add (5)
            dt.Rows.Add(dr)
        Next
Dim FilteredDT As DataTable        
Dim DV As New DataView(dt, SearchCriteria, Nothing, DataViewRowState.CurrentRows)
FilteredDT = DV.ToTable
C1TrueDBGrid1.DataSource = FilteredDT
Robert SchuttSoftware Engineer

Commented:
First things first.

I was writing an answer to the post before your last post (about rewriting the For Each) but am unclear on what you're asking.

In this code:

xdlink.SelectNodes (CountryUser_ID IN (x) and CountryOrigin_ID in (y) and manufacturer_ID IN (z))

Open in new window


does CountryUser_ID hold 1 value?

In that case it's possible (using the xpath function 'contains' and a little concatenation trick), otherwise see my previous code where I split the string and use that to build a selection string for use in the xpath argument to SelectNodes.

Author

Commented:
Sorry for confusing matters, I'm trying your code now but running into some issues with Moving to Next/Previous records, running more test, will get back to you shortly, to answer your last question, CountryUser_ID can have one or more values (i.e. 1,4,5,3). users will be selecting countries from a Grid/Combo box.

On my previous post (Windows project) I was able to put all  selections in a string variable xyzz (1,4,3) and pass those values in my Searchcriteria, but would welcome a better approach (xpath function)for the web version.

Author

Commented:
Hi,

I was having issues with selecting a country from my combobox so I decided to hardcode value = 1 and it works. How do you get the total number of records in dtReceiver? I will also need to Move to Last/First Record. I think the only remaining issue is If I have 1,3,4,5 instead of just 1.

 Private Sub UpdateGrid()
        ' If C1CountryOrigin.SelectedItem IsNot Nothing Then
        Dim dtReceiver As New DataTable
        dtReceiver.Columns.Add(New DataColumn("ID"))
        dtReceiver.Columns.Add(New DataColumn("Name"))
        Dim xdlink As New Xml.XmlDocument, xdReceiver As New Xml.XmlDocument, Link_ID As String, ReceiverID As String, ReceiverID2 As String, Name As String
        xdlink.Load(Server.MapPath("LinkSSADB.xml"))
        xdReceiver.Load(Server.MapPath("CountryUser.xml"))
        Dim iCount As Integer = 0
        Button171.Enabled = False
        Button2.Enabled = False
        For Each xnLink As Xml.XmlNode In xdlink.SelectNodes("/Root/LinkA") '
            Link_ID = xnLink.SelectSingleNode("LinkAID").InnerText
            ReceiverID = xnLink.SelectSingleNode("CountryUser_ID").InnerText
            Dim tmp() As String = ReceiverID.Split(",")
            Dim selectionString As String = ""
            '  If tmp.Contains(C1CountryOrigin.SelectedItem.Value) Then
            If tmp.Contains(1) Then
                iCount += 1
                If iCount < ViewState("CurrentRecord") Then
                    Button171.Enabled = True
                ElseIf iCount > ViewState("CurrentRecord") Then
                    Button2.Enabled = True
                Else
                    For i As Integer = 0 To tmp.Length - 1
                        Dim selectionStringNew As String = "CountryUser_ID='" & tmp(i) & "'"
                        If Not selectionString.Contains(selectionStringNew) Then ' avoid duplicates, although it wouldn't make a difference really
                            If selectionString <> "" Then selectionString &= " or "
                            selectionString &= selectionStringNew
                        End If
                    Next
                    Name = ""
                    For Each xnReceiver As Xml.XmlNode In xdReceiver.SelectNodes("/Root/CountryUserTable[" & selectionString & "]")
                        ReceiverID2 = xnReceiver.SelectSingleNode("CountryUser_ID").InnerText
                        Name = xnReceiver.SelectSingleNode("CountryUser").InnerText
                        dtReceiver.Rows.Add({ReceiverID2, Name})
                    Next
                End If
            End If
        Next
        MsgBox("Total Records")
        MsgBox(dtReceiver.Rows.Count)
        C1GridView5.DataSource = dtReceiver
        C1GridView5.DataBind()
        ' End If

Thanks,

Victor
Robert SchuttSoftware Engineer

Commented:
I think I'm getting somewhere, at least for the first selection, this will have to be expanded for the others.

The code is not very clear in itself maybe so first the explanation of what I'm doing:

* using all selected values from a listbox with countries, build an xpath selection string that returns all Link records where the multivalued CountryUser_ID contains that value. Example: when BEL and FRA are selected, the string will contain:

contains(concat(',', CountryUser_ID, ','), ',1,') or contains(concat(',', CountryUser_ID, ','), ',5,')

Open in new window


* then, to select the countries the previous code would work but to make it consistent I use the same functionality, but note that the arguments are the other way around now because here we are searching for the Country records that have an ID that is contained in the string that we obtained from the previous step. The generated string for the first selected record would be:

contains(',1,2,3,4,', concat(',', CountryUser_ID, ','))

Open in new window


Now, the new code as a whole:

    Private Sub UpdateGrid()
        If C1CountryUser.SelectedItem IsNot Nothing Then
            Dim dtReceiver As New DataTable
            dtReceiver.Columns.Add(New DataColumn("ID"))
            dtReceiver.Columns.Add(New DataColumn("Name"))
            Dim xdlink As New Xml.XmlDocument, xdReceiver As New Xml.XmlDocument, Link_ID As String, ReceiverID As String, ReceiverID2 As String, Name As String
            xdlink.Load(Server.MapPath("LinkSSADB.xml"))
            xdReceiver.Load(Server.MapPath("CountryUser.xml"))
            Dim iCount As Integer = 0
            Button1.Enabled = False
            Button2.Enabled = False
            Dim allSelectionString As String = ""
            For Each oC1selitem As Integer In C1CountryUser.GetSelectedIndices
                If allSelectionString <> "" Then allSelectionString &= " or "
                allSelectionString &= "contains(concat(',', CountryUser_ID, ','), '," & C1CountryUser.Items(oC1selitem).Value & ",')"
            Next
            Me.Label1.Text = allSelectionString
            If Not String.IsNullOrEmpty(allSelectionString) Then
                For Each xnLink As Xml.XmlNode In xdlink.SelectNodes("/Root/LinkA[" & allSelectionString & "]")
                    Link_ID = xnLink.SelectSingleNode("LinkAID").InnerText
                    ReceiverID = xnLink.SelectSingleNode("CountryUser_ID").InnerText
                    iCount += 1
                    If iCount < ViewState("CurrentRecord") Then
                        Button1.Enabled = True
                    ElseIf iCount > ViewState("CurrentRecord") Then
                        Button2.Enabled = True
                    Else
                        For Each xnReceiver As Xml.XmlNode In xdReceiver.SelectNodes("/Root/CountryUserTable[contains('," & ReceiverID & ",', concat(',', CountryUser_ID, ','))]")
                            ReceiverID2 = xnReceiver.SelectSingleNode("CountryUser_ID").InnerText
                            Name = xnReceiver.SelectSingleNode("CountryUser").InnerText
                            dtReceiver.Rows.Add({ReceiverID2, Name})
                        Next
                    End If
                Next
                GridView1.DataSource = dtReceiver
                GridView1.DataBind()
            End If
        End If
    End Sub

Open in new window

Robert SchuttSoftware Engineer

Commented:
sorry, our posts keep crossing each other but actually this may be the solution in general.

Author

Commented:
Hi,

I'm on transit now but will keep checking your post, I will try the code and get back to you. Using this approach can we search LinkSSADB.xml using multiple data elemennts? for example

CountryUser_ID IN (1,3,4) and CountryOrigin_ID IN (2,4,5) and Manufacturer_ID IN (4)

Thanks,

V.

Author

Commented:
Hi,

I tried your code but C1CountryUser.GetSelectedIndices gives me an error (Not a member of C1.C1Combobox...), It's third party Gridcontrol from ComponentOne, this might be the problem, I tried to hard code the values using (1,2,4,5), but it doesn'yt like the syntax.



 If C1CountryUser.SelectedItem IsNot Nothing Then
            Dim dtReceiver As New DataTable
            dtReceiver.Columns.Add(New DataColumn("ID"))
            dtReceiver.Columns.Add(New DataColumn("Name"))
            Dim xdlink As New Xml.XmlDocument, xdReceiver As New Xml.XmlDocument, Link_ID As String, ReceiverID As String, ReceiverID2 As String, Name As String
            xdlink.Load(Server.MapPath("LinkSSADB.xml"))
            xdReceiver.Load(Server.MapPath("CountryUser.xml"))
            Dim iCount As Integer = 0
            NextA.Enabled = False
            Previous.Enabled = False
            Dim allSelectionString As String = ""
            'For Each oC1selitem As Integer In C1CountryUser.GetSelectedIndices
            For Each oC1selitem As Integer In (1,2,3)
                If allSelectionString <> "" Then allSelectionString &= " or "
                allSelectionString &= "contains(concat(',', CountryUser_ID, ','), '," & C1CountryUser.Items(oC1selitem).Value & ",')"
            Next
            Me.Label14.Text = allSelectionString
            If Not String.IsNullOrEmpty(allSelectionString) Then
                For Each xnLink As Xml.XmlNode In xdlink.SelectNodes("/Root/LinkA[" & allSelectionString & "]")
                    Link_ID = xnLink.SelectSingleNode("LinkAID").InnerText
                    ReceiverID = xnLink.SelectSingleNode("CountryUser_ID").InnerText
                    iCount += 1
                    If iCount < ViewState("CurrentRecord") Then
                        NextA.Enabled = True
                    ElseIf iCount > ViewState("CurrentRecord") Then
                        Button2.Enabled = True
                    Else
                        For Each xnReceiver As Xml.XmlNode In xdReceiver.SelectNodes("/Root/CountryUserTable[contains('," & ReceiverID & ",', concat(',', CountryUser_ID, ','))]")
                            ReceiverID2 = xnReceiver.SelectSingleNode("CountryUser_ID").InnerText
                            Name = xnReceiver.SelectSingleNode("CountryUser").InnerText
                            dtReceiver.Rows.Add({ReceiverID2, Name})
                        Next
                    End If
                Next
                C1GridView5.DataSource = dtReceiver
                C1GridView5.DataBind()
            End If
        End If
Robert SchuttSoftware Engineer

Commented:
Yes, sure that's possible but I was hoping that by providing a general solution and explain how the code works you can combine multiple queries in the way that you need without me needing to recreate all the other xml files and listboxes. For example, repeat the code for Manufacturer and concatenate the two selection strings like this:

"(" & allSelectionStrings & " and " & allSelectionStringsManufacturerer & ")"

Open in new window


You shouldn't have to hard-code anything anymore but you do need to look carefully what you're putting where.

If .SelectedIndices doesn't work, just use your own working code to make this string. That shouldn't be the difficult part.

Author

Commented:
Hi again,

I can't run the project because of the error in my previous post but is the code below the approach you would take when searching for multiple elements in LinkSSADB.xml?  I  don't think it would work without concatenating an "AND" statement for each element right?
The code is for CountryUser and CountryOrigin are using the same Country.xml file. Which will be the case for some of my xml files.

Private Sub UpdateGrid()
        If C1CountryUser.SelectedItem IsNot Nothing Then
            Dim dtReceiver As New DataTable
            dtReceiver.Columns.Add(New DataColumn("ID"))
            dtReceiver.Columns.Add(New DataColumn("Name"))
            Dim xdlink As New Xml.XmlDocument, xdReceiver As New Xml.XmlDocument, Link_ID As String, ReceiverID As String, ReceiverID2 As String, xdDonor As New Xml.XmlDocument, DonorID As String, DonorID2, Name As String
            xdlink.Load(Server.MapPath("LinkSSADB.xml"))
            xdReceiver.Load(Server.MapPath("Country.xml"))

            Dim dtDonor As New DataTable
            dtDonor.Columns.Add(New DataColumn("ID"))
            dtDonor.Columns.Add(New DataColumn("Name"))
            'xdDonor.Load(Server.MapPath("CountryUser.xml"))

            Dim iCount As Integer = 0
            NextA.Enabled = False
            Previous.Enabled = False
            Dim allSelectionString As String = ""
            Dim allSelectionStringA As String = ""
            For Each oC1selitem As Integer In C1CountryUser.GetSelectedIndices
                'For Each oC1selitem As Integer In (1,2,3)
                If allSelectionString <> "" Then allSelectionString &= " or "
                allSelectionString &= "contains(concat(',', CountryUser_ID, ','), '," & C1CountryUser.Items(oC1selitem).Value & ",')"
            Next

            For Each oC1selitem As Integer In C1CountryOrigin.GetSelectedIndices
                If allSelectionString <> "" Then allSelectionString &= " or "
                allSelectionStringA &= "contains(concat(',', CountryOrigin_ID, ','), '," & C1CountryOrigin.Items(oC1selitem).Value & ",')"
            Next
            Me.Label14.Text = allSelectionString
            Me.Label15.Text = allSelectionString
            If Not String.IsNullOrEmpty(allSelectionString) Then
                For Each xnLink As Xml.XmlNode In xdlink.SelectNodes("/Root/LinkA[" & allSelectionString & "]")
                    Link_ID = xnLink.SelectSingleNode("LinkAID").InnerText
                    ReceiverID = xnLink.SelectSingleNode("CountryUser_ID").InnerText
                    iCount += 1
                    If iCount < ViewState("CurrentRecord") Then
                        NextA.Enabled = True
                    ElseIf iCount > ViewState("CurrentRecord") Then
                        Button2.Enabled = True
                    Else
                        For Each xnReceiver As Xml.XmlNode In xdReceiver.SelectNodes("/Root/CountryTable[contains('," & ReceiverID & ",', concat(',', Country_ID, ','))]")
                            ReceiverID2 = xnReceiver.SelectSingleNode("Country_ID").InnerText
                            Name = xnReceiver.SelectSingleNode("Country").InnerText
                            dtReceiver.Rows.Add({ReceiverID2, Name})
                        Next
                    End If
                Next
                C1GridView5.DataSource = dtReceiver
                C1GridView5.DataBind()
            End If

            If Not String.IsNullOrEmpty(allSelectionStringA) Then
                For Each xnLink As Xml.XmlNode In xdlink.SelectNodes("/Root/LinkA[" & allSelectionStringA & "]")
                    Link_ID = xnLink.SelectSingleNode("LinkAID").InnerText
                    DonorID = xnLink.SelectSingleNode("CountryOrigin_ID").InnerText
                    iCount += 1
                    If iCount < ViewState("CurrentRecord") Then
                        NextA.Enabled = True
                    ElseIf iCount > ViewState("CurrentRecord") Then
                        Button2.Enabled = True
                    Else
                        For Each xnReceiver As Xml.XmlNode In xdDonor.SelectNodes("/Root/CountryTable[contains('," & DonorID & ",', concat(',', Country_ID, ','))]")
                            DonorID2 = xnReceiver.SelectSingleNode("Country_ID").InnerText
                            Name = xnReceiver.SelectSingleNode("Country").InnerText
                            dtDonor.Rows.Add({DonorID2, Name})
                        Next
                    End If
                Next
                C1GridView6.DataSource = dtReceiver
                C1GridView6.DataBind()
            End If
        End If

Author

Commented:
Hi,

Just noticed your post, I will resolve the GetSelectindices issue, but for now is there a way to hard code the balue? it doesn't like "For Each oC1selitem As Integer In (1,2,3)"

ALso where in the code from my last post do I include:

"(" & allSelectionStrings & " and " & allSelectionStringsA & ")"

I'm still not too clear on how the code is functioning.

Thanks,

V.

Author

Commented:
Hi,

I was able to resolve the GetSelectedIndicies issue, tried the code below but no data appears on the grid. My country file changes but Link_SSADB remained the same. Can you please help me fix the code.


<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<Root>
  <CountryTable>
    <Country_ID>1</Country_ID>
    <Country>BEL</Country>
  </CountryTable>
  <CountryTable>
    <Country_ID>2</Country_ID>
    <Country>CAN</Country>
  </CountryTable>
  <CountryTable>
    <Country_ID>3</Country_ID>
    <Country>CZE</Country>
  </CountryTable>
  <CountryTable>
    <Country_ID>4</Country_ID>
    <Country>DNK</Country>
  </CountryTable>
  <CountryTable>
    <Country_ID>5</Country_ID>
    <Country>FRA</Country>
  </CountryTable>
  <CountryTable>
    <Country_ID>6</Country_ID>
    <Country>DEU</Country>
  </CountryTable>


Code:

Private Sub UpdateGrid()
        If C1CountryUser.SelectedItem IsNot Nothing Then
            Dim dtReceiver As New DataTable
            dtReceiver.Columns.Add(New DataColumn("ID"))
            dtReceiver.Columns.Add(New DataColumn("Name"))
            Dim xdlink As New Xml.XmlDocument, xdReceiver As New Xml.XmlDocument, Link_ID As String, ReceiverID As String, ReceiverID2 As String, DonorID As String, DonorID2, Name As String
            xdlink.Load(Server.MapPath("LinkSSADB.xml"))
            xdReceiver.Load(Server.MapPath("Country.xml"))

            Dim dtDonor As New DataTable
            dtDonor.Columns.Add(New DataColumn("ID"))
            dtDonor.Columns.Add(New DataColumn("Name"))


            Dim iCount As Integer = 0
            NextA.Enabled = False
            Previous.Enabled = False
            Dim allSelectionString As String = ""
            Dim allSelectionStringA As String = ""
            For Each oC1selitem As Integer In C1CountryUser.SelectedIndices
                If allSelectionString <> "" Then allSelectionString &= " or "
                allSelectionString &= "contains(concat(',', Country_ID, ','), '," & C1CountryUser.Items(oC1selitem).Value & ",')"
            Next

            For Each oC1selitem As Integer In C1CountryOrigin.SelectedIndices
                If allSelectionString <> "" Then allSelectionString &= " or "
                allSelectionStringA &= "contains(concat(',', Country_ID, ','), '," & C1CountryOrigin.Items(oC1selitem).Value & ",')"
            Next
            Me.Label14.Text = allSelectionString
            If Not String.IsNullOrEmpty(allSelectionString) Then
                For Each xnLink As Xml.XmlNode In xdlink.SelectNodes("/Root/LinkA[" & allSelectionString & "]")
                    Link_ID = xnLink.SelectSingleNode("LinkAID").InnerText
                    ReceiverID = xnLink.SelectSingleNode("CountryUser_ID").InnerText
                    iCount += 1
                    If iCount < ViewState("CurrentRecord") Then
                        NextA.Enabled = True
                    ElseIf iCount > ViewState("CurrentRecord") Then
                        Button2.Enabled = True
                    Else
                        For Each xnReceiver As Xml.XmlNode In xdReceiver.SelectNodes("/Root/CountryTable[contains('," & ReceiverID & ",', concat(',', Country_ID, ','))]")
                            ReceiverID2 = xnReceiver.SelectSingleNode("Country_ID").InnerText
                            Name = xnReceiver.SelectSingleNode("Country").InnerText
                            dtReceiver.Rows.Add({ReceiverID2, Name})
                        Next
                    End If
                Next
                C1GridView5.DataSource = dtReceiver
                C1GridView5.DataBind()
            End If

            If Not String.IsNullOrEmpty(allSelectionStringA) Then
                For Each xnLink As Xml.XmlNode In xdlink.SelectNodes("/Root/LinkA[" & allSelectionStringA & "]")
                    Link_ID = xnLink.SelectSingleNode("LinkAID").InnerText
                    DonorID = xnLink.SelectSingleNode("CountryOrigin_ID").InnerText
                    iCount += 1
                    If iCount < ViewState("CurrentRecord") Then
                        NextA.Enabled = True
                    ElseIf iCount > ViewState("CurrentRecord") Then
                        Button2.Enabled = True
                    Else
                        For Each xnReceiver As Xml.XmlNode In xdReceiver.SelectNodes("/Root/CountryTable[contains('," & DonorID & ",', concat(',', Country_ID, ','))]")
                            DonorID2 = xnReceiver.SelectSingleNode("Country_ID").InnerText
                            Name = xnReceiver.SelectSingleNode("Country").InnerText
                            dtDonor.Rows.Add({DonorID2, Name})
                        Next
                    End If
                Next
                C1GridView6.DataSource = dtDonor
                C1GridView6.DataBind()
            End If
        End If
End Sub
Robert SchuttSoftware Engineer

Commented:
Ok I will try, but I'll need some more time.
Robert SchuttSoftware Engineer

Commented:
Again, upon re-reading your last request, I get lost a bit. Here's why:

I see now you put the results in 2 separate GridViews. This would mean you don't need to make 1 big selection with AND's but instead exactly how you have done it.

However, then you would need separate buttons to move through the results and separate hidden fields to remember the current position as well, because now that is crossing over in a wrong way.
Robert SchuttSoftware Engineer

Commented:
Well, maybe I was too hasty with that last remark. I'm trying different combinations and I think I found what you need.

Now I will try to re-write my code with your variables.

Author

Commented:
Thank you again for your help, will check the post later today. Sorry for not being clear from the beginning.
Robert SchuttSoftware Engineer

Commented:
Here it is:

    Protected Sub C1CountryUser_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles C1CountryUser.SelectedIndexChanged, C1CountryOrigin.SelectedIndexChanged
        ViewState("CurrentRecord") = 1
        UpdateGrid()
    End Sub

    Protected Sub ButtonPrev_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ButtonPrev.Click
        ViewState("CurrentRecord") -= 1
        UpdateGrid()
    End Sub

    Protected Sub ButtonNext_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ButtonNext.Click
        ViewState("CurrentRecord") += 1
        UpdateGrid()
    End Sub

    Private Sub UpdateGrid()
        Dim xdlink As New Xml.XmlDocument, xdReceiver As New Xml.XmlDocument, Link_ID As String, ReceiverID As String, ReceiverID2 As String, DonorID As String, DonorID2 As String, Name As String
        xdlink.Load(Server.MapPath("LinkSSADB.xml"))
        xdReceiver.Load(Server.MapPath("CountryUser.xml"))

        Dim allSelectionString1 As String = ""
        For itemCounter As Integer = 0 To C1CountryUser.Items.Count - 1
            If C1CountryUser.Items(itemCounter).Selected Then
                If allSelectionString1 <> "" Then allSelectionString1 &= " or "
                allSelectionString1 &= "contains(concat(',', CountryUser_ID, ','), '," & C1CountryUser.Items(itemCounter).Value & ",')"
            End If
        Next

        Dim allSelectionString2 As String = ""
        For itemCounter As Integer = 0 To C1CountryOrigin.Items.Count - 1
            If C1CountryOrigin.Items(itemCounter).Selected Then
                If allSelectionString2 <> "" Then allSelectionString2 &= " or "
                allSelectionString2 &= "contains(concat(',', CountryOrigin_ID, ','), '," & C1CountryOrigin.Items(itemCounter).Value & ",')"
            End If
        Next

        Dim dtReceiver As New DataTable
        dtReceiver.Columns.Add(New DataColumn("ID"))
        dtReceiver.Columns.Add(New DataColumn("Name"))

        Dim dtDonor As New DataTable
        dtDonor.Columns.Add(New DataColumn("ID"))
        dtDonor.Columns.Add(New DataColumn("Name"))

        Dim iCount As Integer = 0
        Dim allSelectionStringOverall As String = "(" & allSelectionString1 & ") and (" & allSelectionString2 & ")"
        Me.Label1.Text = allSelectionStringOverall
        ButtonPrev.Enabled = False
        ButtonNext.Enabled = False
        If Not String.IsNullOrEmpty(allSelectionString1) AndAlso Not String.IsNullOrEmpty(allSelectionString2) Then
            Dim selectedNodes As Xml.XmlNodeList = xdlink.SelectNodes("/Root/LinkA[" & allSelectionStringOverall & "]")
            For Each xnLink As Xml.XmlNode In selectedNodes
                Link_ID = xnLink.SelectSingleNode("LinkAID").InnerText
                ReceiverID = xnLink.SelectSingleNode("CountryUser_ID").InnerText
                DonorID = xnLink.SelectSingleNode("CountryOrigin_ID").InnerText
                iCount += 1
                If iCount < ViewState("CurrentRecord") Then
                    ButtonPrev.Enabled = True
                ElseIf iCount > ViewState("CurrentRecord") Then
                    ButtonNext.Enabled = True
                Else
                    LabelRecord.Text = " ( " & iCount & "/ " & selectedNodes.Count & ") "
                    For Each xnReceiver As Xml.XmlNode In xdReceiver.SelectNodes("/Root/CountryTable[contains('," & ReceiverID & ",', concat(',', Country_ID, ','))]")
                        ReceiverID2 = xnReceiver.SelectSingleNode("Country_ID").InnerText
                        Name = xnReceiver.SelectSingleNode("Country").InnerText
                        dtReceiver.Rows.Add({ReceiverID2, Name})
                    Next
                    For Each xnReceiver As Xml.XmlNode In xdReceiver.SelectNodes("/Root/CountryTable[contains('," & DonorID & ",', concat(',', Country_ID, ','))]")
                        DonorID2 = xnReceiver.SelectSingleNode("Country_ID").InnerText
                        Name = xnReceiver.SelectSingleNode("Country").InnerText
                        dtDonor.Rows.Add({DonorID2, Name})
                    Next
                End If
            Next
        Else
            LabelRecord.Text = " ( 0 / 0 ) "
        End If
        C1GridView5.DataSource = dtReceiver
        C1GridView5.DataBind()
        C1GridView6.DataSource = dtDonor
        C1GridView6.DataBind()
    End Sub

Open in new window


This is my page by the way:

    <form id="form1" runat="server">
    <div>
        <asp:HiddenField ID="CurrentRecord" runat="server" ViewStateMode="Enabled" />
        <asp:XmlDataSource ID="XmlDataSource1" runat="server" DataFile="~/CountryUser.xml" TransformFile="~/CountryToListbox.xslt"/>
        <asp:Table ID="Table1" runat="server" Height="300px" Width="600px" 
            BorderColor="Silver" BorderStyle="Dotted" BorderWidth="1px" CellPadding="2" 
            CellSpacing="1">
            <asp:TableRow runat="server">
                <asp:TableCell runat="server" ColumnSpan="3" HorizontalAlign="Center">Header</asp:TableCell>
            </asp:TableRow>
            <asp:TableRow runat="server" HorizontalAlign="Left" VerticalAlign="Top">
                <asp:TableCell runat="server">
                    <asp:ListBox ID="C1CountryUser"   runat="server" Rows="9" DataSourceID="XmlDataSource1" DataTextField="CountryName" DataValueField="CountryID" AutoPostBack="true" ViewStateMode="Enabled" SelectionMode="Multiple" />
                    <asp:ListBox ID="C1CountryOrigin" runat="server" Rows="9" DataSourceID="XmlDataSource1" DataTextField="CountryName" DataValueField="CountryID" AutoPostBack="true" ViewStateMode="Enabled" SelectionMode="Multiple" />
                </asp:TableCell>
                <asp:TableCell runat="server"><asp:GridView ID="C1GridView5" runat="server" ViewStateMode="Disabled"/></asp:TableCell>
                <asp:TableCell runat="server"><asp:GridView ID="C1GridView6" runat="server" ViewStateMode="Disabled"/></asp:TableCell>
            </asp:TableRow>
            <asp:TableRow runat="server" HorizontalAlign="Left" VerticalAlign="Top">
                <asp:TableCell runat="server" ColumnSpan="3" HorizontalAlign="Center"><asp:Button ID="ButtonPrev" runat="server" Text="Prev" /><asp:Label ID="LabelRecord" runat="server" Text="Label"></asp:Label><asp:Button ID="ButtonNext" runat="server" Text="Next" /></asp:TableCell>
            </asp:TableRow>
            <asp:TableRow runat="server">
                <asp:TableCell runat="server" ColumnSpan="3" HorizontalAlign="Center">TEST selectionstring: <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label></asp:TableCell>
            </asp:TableRow>
            <asp:TableRow runat="server">
                <asp:TableCell runat="server" ColumnSpan="3" HorizontalAlign="Center">Footer</asp:TableCell>
            </asp:TableRow>
        </asp:Table>
    </div>
    </form>

Open in new window

Robert SchuttSoftware Engineer

Commented:
Don't be sorry! In the beginning I thought it was not possible what you wanted. Now I think it's pretty amazing what you're making. I have learned something about application design and about myself ;-)

Author

Commented:
I'm glad you enjoy helping others :-), you have definately helped me.

Thank you very much for the code, it is very helpful. My only concern is with
Dim allSelectionStringOverall As String = "(" & allSelectionString1 & ") and (" & allSelectionString2 & ")"

For example if I have 3 controls that gives me allSelectionString1, allSelectionString2 and allSelectionString3, I need to include them in allSelectionStringOverall only when the user selects that from the controls.

If the user did not select a country from CountryOrigin, this code would return an error, is it possible to build this string based on the controls slected?

For example the following three controls will give me

allSelectionString1 CountryUser
allSelectionString2 CountryOrigin
allSelectionString3 Manufacturer

If I decide to only search for CountryUser and Manufacturer, I should only build my search string with:

Dim allSelectionStringOverall As String = "(" & allSelectionString1 & ") and (" & allSelectionString3 & ")"


There should be no need to create allSelectionString2. Please take a look at the sample with the Windows version, it basically the same thing except the data is displayed in one Grid, instead of multiple Grids.

Thanks,

V.

Author

Commented:
Hi,

Below is an example of the code for the Windows version. For the Web version we would use Control.Selected.Item.Value <> "" instead of textbox.text <> "" or If Not (TextBox2.Text = String.Empty). The astrixState variable is set if the user decides to use AND or NOT IN, it's not important for what we are trying to do.

Dim SearchCriteria As String = "Link_ID <> -1"
        If TextBox1.Text <> "" Then
            SearchCriteria &= " AND Manufacturer IN (" & TextBox1.Text & " )"
        End If
       
        If Not (TextBox2.Text = String.Empty) Then
            If astrixState = 0 Then
                SearchCriteria &= " AND Donor  IN (" & TextBox2.Text & " )"
            End If
 
            If astrixState = 1 Then
                SearchCriteria &= " AND Donor  NOT IN (" & TextBox2.Text & ")"
            End If
        End If
 
     If Not (TextBox3.Text = String.Empty) Then
            If astrixState = 0 Then
                SearchCriteria &= " AND Receiver  IN (" & TextBox3.Text & " )"
            End If
            If astrixState = 1 Then
                SearchCriteria &= " AND Receiver NOT IN (" & TextBox3.Text & ")"
            End If
        End If
Robert SchuttSoftware Engineer

Commented:
You're absolutely right, I had just assumed it should only return results when every choice had at least 1 selected item.

There's a number of solutions, one of the easiest is probably:

        Dim allSelectionStringOverall As String = ""
        For Each selString As String In {allSelectionString1, allSelectionString2} ' add others here
            If selString <> "" Then
                If allSelectionStringOverall <> "" Then allSelectionStringOverall &= " and "
                allSelectionStringOverall &= selString
            End If
        Next
        If allSelectionStringOverall <> "" Then allSelectionStringOverall = "[" & allSelectionStringOverall & "]"
        Me.Label1.Text = allSelectionStringOverall
        ButtonPrev.Enabled = False
        ButtonNext.Enabled = False
        Dim selectedNodes As Xml.XmlNodeList = xdlink.SelectNodes("/Root/LinkA" & allSelectionStringOverall)

Open in new window


Note that in the last line of this piece of code the square brackets are gone (they are added earlier if there's anything in the selection string), it's now possible to start without a selection and have all records to choose from. Complete code:

    Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
        If Not IsPostBack Then ' first time
            ViewState("CurrentRecord") = 1
            UpdateGrid()
        End If
    End Sub

    Protected Sub C1CountryUser_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles C1CountryUser.SelectedIndexChanged, C1CountryOrigin.SelectedIndexChanged
        ViewState("CurrentRecord") = 1
        UpdateGrid()
    End Sub

    Protected Sub ButtonPrev_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ButtonPrev.Click
        ViewState("CurrentRecord") -= 1
        UpdateGrid()
    End Sub

    Protected Sub ButtonNext_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ButtonNext.Click
        ViewState("CurrentRecord") += 1
        UpdateGrid()
    End Sub

    Private Sub UpdateGrid()
        Dim xdlink As New Xml.XmlDocument, xdReceiver As New Xml.XmlDocument, Link_ID As String, ReceiverID As String, ReceiverID2 As String, DonorID As String, DonorID2 As String, Name As String
        xdlink.Load(Server.MapPath("LinkSSADB.xml"))
        xdReceiver.Load(Server.MapPath("CountryUser.xml"))

        Dim allSelectionString1 As String = ""
        For itemCounter As Integer = 0 To C1CountryUser.Items.Count - 1
            If C1CountryUser.Items(itemCounter).Selected Then
                If allSelectionString1 <> "" Then allSelectionString1 &= " or "
                allSelectionString1 &= "contains(concat(',', CountryUser_ID, ','), '," & C1CountryUser.Items(itemCounter).Value & ",')"
            End If
        Next

        Dim allSelectionString2 As String = ""
        For itemCounter As Integer = 0 To C1CountryOrigin.Items.Count - 1
            If C1CountryOrigin.Items(itemCounter).Selected Then
                If allSelectionString2 <> "" Then allSelectionString2 &= " or "
                allSelectionString2 &= "contains(concat(',', CountryOrigin_ID, ','), '," & C1CountryOrigin.Items(itemCounter).Value & ",')"
            End If
        Next

        Dim dtReceiver As New DataTable
        dtReceiver.Columns.Add(New DataColumn("ID"))
        dtReceiver.Columns.Add(New DataColumn("Name"))

        Dim dtDonor As New DataTable
        dtDonor.Columns.Add(New DataColumn("ID"))
        dtDonor.Columns.Add(New DataColumn("Name"))

        Dim iCount As Integer = 0
        Dim allSelectionStringOverall As String = ""
        For Each selString As String In {allSelectionString1, allSelectionString2}
            If selString <> "" Then
                If allSelectionStringOverall <> "" Then allSelectionStringOverall &= " and "
                allSelectionStringOverall &= selString
            End If
        Next
        If allSelectionStringOverall <> "" Then allSelectionStringOverall = "[" & allSelectionStringOverall & "]"
        Me.Label1.Text = allSelectionStringOverall
        ButtonPrev.Enabled = False
        ButtonNext.Enabled = False
        Dim selectedNodes As Xml.XmlNodeList = xdlink.SelectNodes("/Root/LinkA" & allSelectionStringOverall)
        For Each xnLink As Xml.XmlNode In selectedNodes
            Link_ID = xnLink.SelectSingleNode("LinkAID").InnerText
            ReceiverID = xnLink.SelectSingleNode("CountryUser_ID").InnerText
            DonorID = xnLink.SelectSingleNode("CountryOrigin_ID").InnerText
            iCount += 1
            If iCount < ViewState("CurrentRecord") Then
                ButtonPrev.Enabled = True
            ElseIf iCount > ViewState("CurrentRecord") Then
                ButtonNext.Enabled = True
            Else
                For Each xnReceiver As Xml.XmlNode In xdReceiver.SelectNodes("/Root/CountryTable[contains('," & ReceiverID & ",', concat(',', Country_ID, ','))]")
                    ReceiverID2 = xnReceiver.SelectSingleNode("Country_ID").InnerText
                    Name = xnReceiver.SelectSingleNode("Country").InnerText
                    dtReceiver.Rows.Add({ReceiverID2, Name})
                Next
                For Each xnReceiver As Xml.XmlNode In xdReceiver.SelectNodes("/Root/CountryTable[contains('," & DonorID & ",', concat(',', Country_ID, ','))]")
                    DonorID2 = xnReceiver.SelectSingleNode("Country_ID").InnerText
                    Name = xnReceiver.SelectSingleNode("Country").InnerText
                    dtDonor.Rows.Add({DonorID2, Name})
                Next
            End If
        Next
        LabelRecord.Text = " ( " & Math.Min(ViewState("CurrentRecord"), selectedNodes.Count) & "/ " & selectedNodes.Count & ") "
        C1GridView5.DataSource = dtReceiver
        C1GridView5.DataBind()
        C1GridView6.DataSource = dtDonor
        C1GridView6.DataBind()
    End Sub

Open in new window

Author

Commented:
Hi again,
I need to explain to you more of what I’m trying to do as it will influence the approach you take to help me solve my issues.
1. The first approach is for the user to search multiple data elements in LinkSSADB.xml (We are working on now)
2. The second part which I did not mention is LinkSSADB.xml is linked to other Link files by LinkAID
For example: LinkID2 = LinkAID   LinkAID was initially created in LinkSSADB.xml
Now if my Query returns 3 rows in LinkSSADB.xml (LinkAID = 4, LinkAID = 5, LinkAID = 10) LinkID2 is automatically set to those same values for LinkSSADBx.xml, LinkSSADBy.xml , LinkSSADBz.xml
LinkSSADBy.xml (example)

<LinkTable>
<LinkID2> 3 </LinkID2> 3
<ITemA></ItemA>
<ITemA></ItemA>
<ITemA></ItemA>
<LinkTable>
LinkID2 = 3 is related to same record of LInkAID = 3
My question is can we still use the same approach to display the data in other  Link files linked to LinkSSADB.xml?
Because now we need to consider LinkID2 not the IDs of the elements, like we did for CountryUser_ID,
CountryOrigin_ID. I hope I didn’t confuse matters, lets try to resolve this issue, hopefully it will all fall into place with the other link files, just thought I’d my the complete approach to your attention.
Robert SchuttSoftware Engineer

Commented:
Small but important error on my part: in the first piece of code in my previous post, change line 5:

allSelectionStringOverall &= "(" & selString & ")"

Open in new window


if you want a negation, insert before that line:

If astrixState = 1 Then allSelectionStringOverall &= "not "

Open in new window

Author

Commented:
Thank You very much for the code, will try it and get back to you.

Author

Commented:
Hi,

What does the code below? Can you please to put comments next to the code to help me better understand?  Thanks.

1. Dim allSelectionString1 As String = ""
        For itemCounter As Integer = 0 To C1CountryUser.Items.Count - 1
            If C1CountryUser.Items(itemCounter).Selected Then
                If allSelectionString1 <> "" Then allSelectionString1 &= " or "
                allSelectionString1 &= "contains(concat(',', CountryUser_ID, ','), '," & C1CountryUser.Items(itemCounter).Value & ",')"
            End If
        Next

2. For Each selString As String In {allSelectionString1, allSelectionString2}
            If selString <> "" Then
                If allSelectionStringOverall <> "" Then allSelectionStringOverall &= " and "
                allSelectionStringOverall &= selString
            End If
        Next
Robert SchuttSoftware Engineer

Commented:
First, the question about the other xml files. That's possible with a construction like:

otherXmlFile.SelectSingleNode("//LinkTable[LinkID2='" & LinkAID & "']")

Open in new window


Then the code explanation. I tried that before with the description in text before posting the code but I'll try again inside the code. Also, if you have a 'debugging' Label1 like I used in the code you can follow what's being put in the selectionString according to selections in the listboxes.

1.
Dim allSelectionString1 As String = ""

' Loop through all items (I changed it because SelectedIndices was not available)
For itemCounter As Integer = 0 To C1CountryUser.Items.Count - 1

  If C1CountryUser.Items(itemCounter).Selected Then

    ' if there's already something in the string then the next 'contains()' will be added but before that we add the operator 'or'
    ' (so the first time this will be skipped)
    If allSelectionString1 <> "" Then allSelectionString1 &= " or "

    ' now follows the part of the xpath query that checks for the value of the current item in the comma delimited element in the Link record
    ' the trick is to prefix and postfix both the string that we're searching for and the string that we're searching in by a comma so that we
    ' don't have to check for special cases like is it at the beginning or end or on its own. we can't just check for '1' because then '12' is
    ' also found, so we check for ,1, but that only works if the string we're searching in like '1,2,3' is changed to ',1,2,3,'
    allSelectionString1 &= "contains(concat(',', CountryUser_ID, ','), '," & C1CountryUser.Items(itemCounter).Value & ",')"

  End If

Next

Open in new window


2. (note I used the enhanced version)
' all the strings we found in earlier searches are now put in an array for easy handling
For Each selString As String In {allSelectionString1, allSelectionString2}

  ' only process strings that are not empty other wise we get an error on "() and ()"
  If selString <> "" Then

    ' just like in the previous block of code, do not use the operator the first time
    If allSelectionStringOverall <> "" Then allSelectionStringOverall &= " and "

    ' if we want to reverse all selections then this is the position in the string we need to insert "not" so the
    ' next part will return true when it is actually false (so it does NOT contain the selected values)
    If astrixState = 1 Then allSelectionStringOverall &= "not "

    ' here the actual query is inserted within parantheses because it can contain multiple calls to 'contains()' separated by 'or' operators
    allSelectionStringOverall &= "(" & selString & ")"

  End If

Next

Open in new window

Author

Commented:
Thank You, I will try to understand it and get back to you latest Monday.

Have a nice weekend.

Victor

Author

Commented:
Hi,

I can't seem to get MsgBox("B") to execute  even when I select a row from from C1CountryUser, any ideas what is wrong? I'm not getting an error message.

Dim allSelectionString1 As String = ""
        For itemCounter As Integer = 0 To C1CountryUser.Items.Count - 1
            MsgBox("A")
            If C1CountryUser.Items(itemCounter).Selected Then
                MsgBox("B")
                If allSelectionString1 <> "" Then allSelectionString1 &= " or "
                allSelectionString1 &= "contains(concat(',', CountryUser_ID, ','), '," & C1CountryUser.Items(itemCounter).Value & ",')"
            End If
        Next
Robert SchuttSoftware Engineer

Commented:
Could that have something to do with the custom components you're using?

Maybe I shouldn't have changed that part, I used another construction first, which didn't work for you but scrolling back I saw you mentioned at some point you got that working:

    Dim allSelectionString1 As String = ""
    For Each selind As Integer In C1CountryUser.GetSelectedIndices
        MsgBox("A")
        If allSelectionString1 <> "" Then allSelectionString1 &= " or "
        allSelectionString1 &= "contains(concat(',', CountryUser_ID, ','), '," & C1CountryUser.Items(selind).Value & ",')"
    Next

Open in new window

Author

Commented:
I think it has to do with the third party control, I was hard coding the values before to test the code. I try to fix the issue with the control. Meanwhile I will try to test code by hard coding the values.

Thanks.
Robert SchuttSoftware Engineer

Commented:
Ok, if you can post which components you are using it should be possible to find. I use a Listbox, had been assuming you would be using something with selectable items as well. Is there no documentation with their controls?

Author

Commented:
Hi,

Sorry for the late reply, I am usig a GridView from ComponentOne. Still looking into it, will get back to you.

Thanks,

V.

Author

Commented:
Hi,

I decided to use the Listbox control that comes with VS2010, but still riunning into issues, I tried options A and B below, but still unable to get a value for allSelectionString1. Also when you select multiple rows from the listbox did you have to hold the Ctrl key? Also below is the code is used to load the listbox controls.

A:
  ' Dim allSelectionString1 As String = ""
        For itemCounter As Integer = 0 To ListBox3.Items.Count - 1
       'MsgBox("A")
        If ListBox3.Items(itemCounter).Selected Then
        MsgBox("B")
        If allSelectionString1 <> "" Then allSelectionString1 &= " or "
        allSelectionString1 &= "contains(concat(',', CountryUser_ID, ','), '," & ListBox3.Items(itemCounter).Value & ",')"
        End If
        Next
        MsgBox(allSelectionString1)

Option B:

Dim allSelectionString1 As String = ""
 For Each selind As Integer In ListBox3.GetSelectedIndices
  MsgBox("A")
  If allSelectionString1 <> "" Then allSelectionString1 &= " or "
   allSelectionString1 &= "contains(concat(',', CountryUser_ID, ','), '," & ListBox3.Items(selind).Value & ",')"
   Next
  MsgBox(allSelectionString1)


Code to Load Listbox:

 Dim CountryUser As New DataSet
 CountryUser.ReadXml(Server.MapPath("~/App_Data/CountryUser.xml"))
            ListBox3.DataSource = CountryUser.Tables(0)
            ListBox3.DataMember = "CountryUser"
            ListBox3.DataTextField = "CountryUser"
            ListBox3.DataValueField = "CountryUser_ID"
            ListBox3.DataBind()
           
             ListBox4.DataSource = CountryUser.Tables(0)
            ListBox4.DataMember = "CountryUser"
            ListBox4.DataTextField = "CountryUser"
            ListBox4.DataValueField = "CountryUser_ID"
            ListBox4.DataBind()

Author

Commented:
Hi,

I am getting the total number of rows with MsgBox(ListBox3.Items.Count) but for example
 If ListBox3.Items(0).Selected Then
is not executing eventhough I selected the firstt row in the Listbox.



Dim allSelectionString1 As String = ""
        For itemCounter As Integer = 0 To ListBox3.Items.Count - 1
            MsgBox("A")
            MsgBox(ListBox3.Items.Count)
            If ListBox3.Items(itemCounter).Selected Then
                MsgBox("B")
                If allSelectionString1 <> "" Then allSelectionString1 &= " or "
                allSelectionString1 &= "contains(concat(',', CountryUser_ID, ','), '," & ListBox3.Items(itemCounter).Value & ",')"
            End If
        Next
        MsgBox(allSelectionString1)
Robert SchuttSoftware Engineer

Commented:
Ok, looking at the documentation I don't see multi-select possibilities in C1Gridview (although there is mention of setting SelectionMode to MultiRow).

Yes, in the standard Listbox you can use the control key to select 2 or more values.

Both of those pieces of code worked for me, maybe check that you use the right properties on the listboxes as well? Including these:

runat="server" AutoPostBack="true" ViewStateMode="Enabled" SelectionMode="Multiple"

Open in new window

Author

Commented:
Ok, made a dum mistake, testing the rest of the code and will get back to you shortly.

Author

Commented:
Hi,

It's working, but only when I select countries from both listboxes, because of the fix AND statement, is there a way to include the AND statement for a control only if a row is elected? I will be using multiple controls to search and users will not always select all the controls?

Also how would you replace the code below to search directly from a listbox selected value(s)
instead of viewing all the nodes.

For Each xnLink As Xml.XmlNode In xdlink.SelectNodes("/Root/LinkA")

 I'm making great progress Thanks to your Help.

Author

Commented:
Hi,

Below is my latest code, when nothing is selected in Listbox4 and get an "AND ()" as part of my search string, which causes not item to be found.

Private Sub UpdateGrid()
        Dim xdlink As New Xml.XmlDocument, xdReceiver As New Xml.XmlDocument, Link_ID As String, ReceiverID As String, ReceiverID2 As String, DonorID As String, DonorID2 As String, Name As String
        xdlink.Load(Server.MapPath("LinkSSADB.xml"))
        xdReceiver.Load(Server.MapPath("CountryUser.xml"))

        Dim allSelectionString1 As String = ""
        For itemCounter As Integer = 0 To ListBox3.Items.Count - 1

            '  MsgBox(ListBox3.Items.Count)
            If ListBox3.Items(itemCounter).Selected Then
                If allSelectionString1 <> "" Then allSelectionString1 &= " or "
                allSelectionString1 &= "contains(concat(',', CountryUser_ID, ','), '," & ListBox3.Items(itemCounter).Value & ",')"
            End If
        Next
           Dim allSelectionString2 As String = ""
        For itemCounter As Integer = 0 To ListBox4.Items.Count - 1
            If ListBox4.Items(itemCounter).Selected Then
                If allSelectionString2 <> "" Then allSelectionString2 &= " or "
                allSelectionString2 &= "contains(concat(',', CountryOrigin_ID, ','), '," & ListBox4.Items(itemCounter).Value & ",')"
            End If
        Next

        Dim dtReceiver As New DataTable
        dtReceiver.Columns.Add(New DataColumn("ID"))
        dtReceiver.Columns.Add(New DataColumn("Name"))

        Dim dtDonor As New DataTable
        dtDonor.Columns.Add(New DataColumn("ID"))
        dtDonor.Columns.Add(New DataColumn("Name"))

        Dim iCount As Integer = 0
        Dim allSelectionStringOverall As String = "(" & allSelectionString1 & ") and (" & allSelectionString2 & ")"

        MsgBox(allSelectionStringOverall)

        Me.Label14.Text = allSelectionStringOverall
        Previous.Enabled = False
        ButtonNext.Enabled = False
        If Not String.IsNullOrEmpty(allSelectionString1) AndAlso Not String.IsNullOrEmpty(allSelectionString2) Then
            Dim selectedNodes As Xml.XmlNodeList = xdlink.SelectNodes("/Root/LinkA[" & allSelectionStringOverall & "]")
            For Each xnLink As Xml.XmlNode In selectedNodes
                Link_ID = xnLink.SelectSingleNode("LinkAID").InnerText
                ReceiverID = xnLink.SelectSingleNode("CountryUser_ID").InnerText
                DonorID = xnLink.SelectSingleNode("CountryUser_ID").InnerText
                iCount += 1
                If iCount < ViewState("CurrentRecord") Then
                    Previous.Enabled = True
                ElseIf iCount > ViewState("CurrentRecord") Then
                    ButtonNext.Enabled = True
                Else
                    Label14.Text = " ( " & iCount & "/ " & selectedNodes.Count & ") "
                    For Each xnReceiver As Xml.XmlNode In xdReceiver.SelectNodes("/Root/CountryUserTable[contains('," & ReceiverID & ",', concat(',', CountryUser_ID, ','))]")
                        ReceiverID2 = xnReceiver.SelectSingleNode("CountryUser_ID").InnerText
                        Name = xnReceiver.SelectSingleNode("CountryUser").InnerText
                        dtReceiver.Rows.Add({ReceiverID2, Name})
                    Next
                    For Each xnReceiver As Xml.XmlNode In xdReceiver.SelectNodes("/Root/CountryUserTable[contains('," & DonorID & ",', concat(',', CountryUser_ID, ','))]")
                        DonorID2 = xnReceiver.SelectSingleNode("CountryUser_ID").InnerText
                        Name = xnReceiver.SelectSingleNode("CountryUser").InnerText
                        dtDonor.Rows.Add({DonorID2, Name})
                    Next
                End If
            Next
        Else
            Label14.Text = " ( 0 / 0 ) "
        End If
        C1GridView5.DataSource = dtReceiver
        C1GridView5.DataBind()
        C1GridView6.DataSource = dtDonor
        C1GridView6.DataBind()

Author

Commented:
Hi,

Is it possible to concatenate allSelectionStringOverall using a similar approach below without using the Textboxes. If necessary I can always use the Textboxes and make them invisible.


Part B:

Dim SearchCriteria As String = "Link_ID <> -1"
        If TextBox1.Text <> "" Then
            SearchCriteria &= " AND Manufacturer IN (" & TextBox1.Text & " )"
        End If
       
        If Not (TextBox2.Text = String.Empty) Then
            If astrixState = 0 Then
                SearchCriteria &= " AND Donor  IN (" & TextBox2.Text & " )"
            End If
 
            If astrixState = 1 Then
                SearchCriteria &= " AND Donor  NOT IN (" & TextBox2.Text & ")"
            End If
        End If
 
     If Not (TextBox3.Text = String.Empty) Then
            If astrixState = 0 Then
                SearchCriteria &= " AND Receiver  IN (" & TextBox3.Text & " )"
            End If
            If astrixState = 1 Then
                SearchCriteria &= " AND Receiver NOT IN (" & TextBox3.Text & ")"
            End If
        End If
     
         Dim dt As New DataTable()
        dt.Columns.Add("Link_ID")
        dt.Columns.Add("Manufacturer")
        dt.Columns.Add("Receiver")
        dt.Columns.Add("Donor")

Author

Commented:
Please disregard the question
*************************************
Also how would you replace the code below to search directly from a listbox selected value(s)
instead of viewing all the nodes.
For Each xnLink As Xml.XmlNode In xdlink.SelectNodes("/Root/LinkA")
**************************************
I just realised I can also use the same approach with just:

Dim allSelectionStringOverall As String = "(" & allSelectionString1 & ")
Robert SchuttSoftware Engineer

Commented:
I'm not sure I understand all of those posts.

Be careful what you copy because it's becoming a bit of a mess.

Earlier I put this next part in but this means you're not processing anything if nothing is selected in either of the listboxes so don't use that anymore.

If Not String.IsNullOrEmpty(allSelectionString1) AndAlso Not String.IsNullOrEmpty(allSelectionString2) Then

Open in new window


For the problem with the empty parts in the string like "and ()" I made a new piece of code, I guess it wasn't clear how that worked but it is a much better solution:

Dim allSelectionStringOverall As String = ""

' all the strings we found in earlier searches are now put in an array for easy handling
For Each selString As String In {allSelectionString1, allSelectionString2} ' add more as needed

  ' only process strings that are not empty other wise we get an error on "() and ()"
  If selString <> "" Then

    ' just like in the previous block of code, do not use the operator the first time
    If allSelectionStringOverall <> "" Then allSelectionStringOverall &= " and "

    ' if we want to reverse all selections then this is the position in the string we need to insert "not" so the
    ' next part will return true when it is actually false (so it does NOT contain the selected values)
    If astrixState = 1 Then allSelectionStringOverall &= "not "

    ' here the actual query is inserted within parantheses because it can contain multiple calls to 'contains()' separated by 'or' operators
    allSelectionStringOverall &= "(" & selString & ")"

  End If

Next

Open in new window

Author

Commented:
Thank You, will get back to you shortly, just realised I wasn't using the latest code you provided me.

Author

Commented:
Hi,

I modified the code as shown below and its working very good, but I am unable to see data in GridView6, any ideas why it is not showing? Both Grids are using the same CountryUser.xml for CountryUser and CountryOrigin. Below is an example of the CountryUser.xml and LinkSSADB.xml formats.

CountryUser.xml format:
 <CountryUserTable>
    <CountryUser_ID>1</CountryUser_ID>
    <CountryUser>BEL</CountryUser>
  </CountryUserTable>


LinkSSADB.xml format:
<LinkA>
    <LinkAID>1</LinkAID>
    <CountryUser_ID>1,6,4</CountryUser_ID>
    <CountryOrigin_ID>1,2,4</CountryOrigin_ID>
  </LinkA>

Latest Code:

Private Sub UpdateGrid()
        Dim astrixState As Integer
        astrixState = 0
        Dim xdlink As New Xml.XmlDocument, xdReceiver As New Xml.XmlDocument, Link_ID As String, ReceiverID As String, ReceiverID2 As String, DonorID As String, DonorID2 As String, Name As String
        xdlink.Load(Server.MapPath("LinkSSADB.xml"))
        xdReceiver.Load(Server.MapPath("CountryUser.xml"))

        Dim allSelectionString1 As String = ""
        For itemCounter As Integer = 0 To ListBox3.Items.Count - 1

            '  MsgBox(ListBox3.Items.Count)
            If ListBox3.Items(itemCounter).Selected Then
                If allSelectionString1 <> "" Then allSelectionString1 &= " or "
                allSelectionString1 &= "contains(concat(',', CountryUser_ID, ','), '," & ListBox3.Items(itemCounter).Value & ",')"
            End If
        Next
        MsgBox(allSelectionString1)

        Dim allSelectionString2 As String = ""
        For itemCounter As Integer = 0 To ListBox4.Items.Count - 1
            If ListBox4.Items(itemCounter).Selected Then
                If allSelectionString2 <> "" Then allSelectionString2 &= " or "
                allSelectionString2 &= "contains(concat(',', CountryOrigin_ID, ','), '," & ListBox4.Items(itemCounter).Value & ",')"
            End If
        Next
        MsgBox(allSelectionString2)
        Dim dtReceiver As New DataTable
        dtReceiver.Columns.Add(New DataColumn("ID"))
        dtReceiver.Columns.Add(New DataColumn("Name"))

        Dim dtDonor As New DataTable
        dtDonor.Columns.Add(New DataColumn("ID"))
        dtDonor.Columns.Add(New DataColumn("Name"))

        Dim iCount As Integer = 0
        '***************************************************************************
        '   Dim allSelectionStringOverall As String = "(" & allSelectionString1 & ") and (" & allSelectionString2 & ")"
        Dim allSelectionStringOverall As String = ""
        ' all the strings we found in earlier searches are now put in an array for easy handling
        For Each selString As String In {allSelectionString1, allSelectionString2} ' add more as needed
            ' only process strings that are not empty other wise we get an error on "() and ()"
            If selString <> "" Then
                ' just like in the previous block of code, do not use the operator the first time
                If allSelectionStringOverall <> "" Then allSelectionStringOverall &= " and "
                ' if we want to reverse all selections then this is the position in the string we need to insert "not" so the
                ' next part will return true when it is actually false (so it does NOT contain the selected values)
                If astrixState = 1 Then allSelectionStringOverall &= "not "
                ' here the actual query is inserted within parantheses because it can contain multiple calls to 'contains()' separated by 'or' operators
                allSelectionStringOverall &= "(" & selString & ")"
            End If
        Next
        MsgBox(allSelectionStringOverall)
        '*************************************************
        Me.Label15.Text = allSelectionStringOverall
        Previous.Enabled = False
        ButtonNext.Enabled = False
        Dim selectedNodes As Xml.XmlNodeList = xdlink.SelectNodes("/Root/LinkA[" & allSelectionStringOverall & "]")
        For Each xnLink As Xml.XmlNode In selectedNodes
            Link_ID = xnLink.SelectSingleNode("LinkAID").InnerText
            ReceiverID = xnLink.SelectSingleNode("CountryUser_ID").InnerText
            DonorID = xnLink.SelectSingleNode("CountryOrigin_ID").InnerText
            iCount += 1
            If iCount < ViewState("CurrentRecord") Then
                Previous.Enabled = True
            ElseIf iCount > ViewState("CurrentRecord") Then
                ButtonNext.Enabled = True
            Else
                Label14.Text = " ( " & iCount & "/ " & selectedNodes.Count & ") "
                For Each xnReceiver As Xml.XmlNode In xdReceiver.SelectNodes("/Root/CountryUserTable[contains('," & ReceiverID & ",', concat(',', CountryUser_ID, ','))]")
                    ReceiverID2 = xnReceiver.SelectSingleNode("CountryUser_ID").InnerText
                    Name = xnReceiver.SelectSingleNode("CountryUser").InnerText
                    dtReceiver.Rows.Add({ReceiverID2, Name})
                Next
                For Each xnReceiver As Xml.XmlNode In xdReceiver.SelectNodes("/Root/CountryUserTable[contains('," & DonorID & ",', concat(',', CountryOrigin_ID, ','))]")
                    DonorID2 = xnReceiver.SelectSingleNode("CountryUser_ID").InnerText
                    Name = xnReceiver.SelectSingleNode("CountryUser").InnerText
                    dtDonor.Rows.Add({DonorID2, Name})
                Next
            End If
        Next
        C1GridView5.DataSource = dtReceiver
        C1GridView5.DataBind()
        C1GridView6.DataSource = dtDonor
        C1GridView6.DataBind()
Robert SchuttSoftware Engineer

Commented:
I think in the last part where you get the countries there's an error (may be mine):

For Each xnReceiver As Xml.XmlNode In xdReceiver.SelectNodes("/Root/CountryUserTable[contains('," & DonorID & ",', concat(',', CountryOrigin_ID, ','))]")

Open in new window


should be:
For Each xnReceiver As Xml.XmlNode In xdReceiver.SelectNodes("/Root/CountryUserTable[contains('," & DonorID & ",', concat(',', Country_ID, ','))]")

Open in new window

Author

Commented:
Hi,

Good News :-)   I fixed the problem with the seconf Grid.

One last related question on this topic. How do you disable  the Next button when you reach the last record or the previous botton when you Move to the First record? and is it possible to add a move First and Move Last button?

Thanks a million for all your Help.

Victor

Author

Commented:
Hi,

One more question, I hope you can also help me on the next issue. If you prefer I can open another post.

Instead of the user searching by selecting rows from the listbox control in some cases the user will need to enter text in a Textbox, the application needs to search the xml file related to that textbox and check if that text exist, and if it does retrieve its ID to serach the LinkSSADB xml file.

For example:

Textbox: Manufacturer

User enters IBM

Programs searches for IBM in Manufacturer.xml,  if found retreive it sID (i.e. Maufacturer_ID = 1)

The search string for LinkSSADB.xml will now include Manufacturer_ID  = 1

If not found, message will return to the user staing IBM was not found.
Robert SchuttSoftware Engineer

Commented:
The ButtonNext gets disabled by default, then only enabled if this part is reached:

ElseIf iCount > ViewState("CurrentRecord") Then
                ButtonNext.Enabled = True

Open in new window


You can add MoveFirst en MoveLast buttons and set them enabled/disabled the same as MovePrevious and MoveNext.

MoveFirst_Click would simply do:
        ViewState("CurrentRecord") = 1
        UpdateGrid()

Open in new window


MoveLast_Click is a bit more difficult, I would probably set it to -1 and then add this after setting selectedNodes (just before "For Each xnLink As Xml.XmlNode In selectedNodes"):

If ViewState("CurrentRecord") = -1 Then ViewState("CurrentRecord") = selectedNodes.Count

Open in new window


So, the complete code, this time not in code tags so I can use bold to show the changes, as it's not adjusted to your other latest changes:

    Protected Sub C1CountryUser_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles C1CountryUser.SelectedIndexChanged, C1CountryOrigin.SelectedIndexChanged
        ViewState("CurrentRecord") = 1
        UpdateGrid()
    End Sub

    Protected Sub ButtonPrev_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ButtonPrev.Click
        ViewState("CurrentRecord") -= 1
        UpdateGrid()
    End Sub

    Protected Sub ButtonNext_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ButtonNext.Click
        ViewState("CurrentRecord") += 1
        UpdateGrid()
    End Sub

    Protected Sub ButtonFirst_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ButtonFirst.Click
        ViewState("CurrentRecord") = 1
        UpdateGrid()
    End Sub


    Protected Sub ButtonLast_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ButtonLast.Click
        ViewState("CurrentRecord") = -1
        UpdateGrid()
    End Sub


    Private Sub UpdateGrid()
        Dim xdlink As New Xml.XmlDocument, xdReceiver As New Xml.XmlDocument, Link_ID As String, ReceiverID As String, ReceiverID2 As String, DonorID As String, DonorID2 As String, Name As String
        xdlink.Load(Server.MapPath("LinkSSADB.xml"))
        xdReceiver.Load(Server.MapPath("CountryUser.xml"))

        Dim allSelectionString1 As String = ""
        For itemCounter As Integer = 0 To C1CountryUser.Items.Count - 1
            If C1CountryUser.Items(itemCounter).Selected Then
                If allSelectionString1 <> "" Then allSelectionString1 &= " or "
                allSelectionString1 &= "contains(concat(',', CountryUser_ID, ','), '," & C1CountryUser.Items(itemCounter).Value & ",')"
            End If
        Next
        Dim allSelectionString2 As String = ""
        For itemCounter As Integer = 0 To C1CountryOrigin.Items.Count - 1
            If C1CountryOrigin.Items(itemCounter).Selected Then
                If allSelectionString2 <> "" Then allSelectionString2 &= " or "
                allSelectionString2 &= "contains(concat(',', CountryOrigin_ID, ','), '," & C1CountryOrigin.Items(itemCounter).Value & ",')"
            End If
        Next

        Dim dtReceiver As New DataTable
        dtReceiver.Columns.Add(New DataColumn("ID"))
        dtReceiver.Columns.Add(New DataColumn("Name"))

        Dim dtDonor As New DataTable
        dtDonor.Columns.Add(New DataColumn("ID"))
        dtDonor.Columns.Add(New DataColumn("Name"))

        Dim iCount As Integer = 0
        Dim allSelectionStringOverall As String = ""
        For Each selString As String In {allSelectionString1, allSelectionString2}
            If selString <> "" Then
                If allSelectionStringOverall <> "" Then allSelectionStringOverall &= " and "
                'If astrix.Checked Then allSelectionStringOverall &= "not "
                allSelectionStringOverall &= "(" & selString & ")"
            End If
        Next
        If allSelectionStringOverall <> "" Then allSelectionStringOverall = "[" & allSelectionStringOverall & "]"

        ButtonPrev.Enabled = False
        ButtonNext.Enabled = False
        ButtonFirst.Enabled = False
        ButtonLast.Enabled = False

        Dim selectedNodes As Xml.XmlNodeList = xdlink.SelectNodes("/Root/LinkA" & allSelectionStringOverall)
        If ViewState("CurrentRecord") = -1 Then ViewState("CurrentRecord") = selectedNodes.Count
        For Each xnLink As Xml.XmlNode In selectedNodes
            Link_ID = xnLink.SelectSingleNode("LinkAID").InnerText
            ReceiverID = xnLink.SelectSingleNode("CountryUser_ID").InnerText
            DonorID = xnLink.SelectSingleNode("CountryOrigin_ID").InnerText
            iCount += 1
            If iCount < ViewState("CurrentRecord") Then
                ButtonPrev.Enabled = True
                ButtonFirst.Enabled = True
            ElseIf iCount > ViewState("CurrentRecord") Then
                ButtonNext.Enabled = True
                ButtonLast.Enabled = True
            Else
                For Each xnReceiver As Xml.XmlNode In xdReceiver.SelectNodes("/Root/CountryTable[contains('," & ReceiverID & ",', concat(',', Country_ID, ','))]")
                    ReceiverID2 = xnReceiver.SelectSingleNode("Country_ID").InnerText
                    Name = xnReceiver.SelectSingleNode("Country").InnerText
                    dtReceiver.Rows.Add({ReceiverID2, Name})
                Next
                For Each xnReceiver As Xml.XmlNode In xdReceiver.SelectNodes("/Root/CountryTable[contains('," & DonorID & ",', concat(',', Country_ID, ','))]")
                    DonorID2 = xnReceiver.SelectSingleNode("Country_ID").InnerText
                    Name = xnReceiver.SelectSingleNode("Country").InnerText
                    dtDonor.Rows.Add({DonorID2, Name})
                Next
            End If
        Next
        LabelRecord.Text = " ( " & Math.Min(ViewState("CurrentRecord"), selectedNodes.Count) & "/ " & selectedNodes.Count & ") "
        C1GridView5.DataSource = dtReceiver
        C1GridView5.DataBind()
        C1GridView6.DataSource = dtDonor
        C1GridView6.DataBind()
    End Sub
Robert SchuttSoftware Engineer

Commented:
The manufacturer question: does it have to be an exact match, or the first partial match? Or will there be more than 1 search result possible?

Will a 'manufacturer not found' message mean that everything else stops or should the rest of the search still go on?
Robert SchuttSoftware Engineer

Commented:
Here's a first implementation for Manufacturer. Don't forget to adjust: For Each selString As String In {allSelectionString1, allSelectionString2, allSelectionString3}

        Dim allSelectionString3 As String = ""
        If Manufacturer.Text <> "" Then
            Dim ManufacturerFound As String = ""
            For Each xnManufacturer As Xml.XmlNode In xdManufacturer.SelectNodes("/Root/ManufacturerTable[contains(Manufacturer, '" & Manufacturer.Text & "')]")
                If allSelectionString3 <> "" Then allSelectionString3 &= " or "
                allSelectionString3 &= "contains(concat(',', Manufacturer_ID, ','), '," & xnManufacturer.SelectSingleNode("Manufacturer_ID").InnerText & ",')"
                If ManufacturerFound <> "" Then ManufacturerFound &= ", "
                ManufacturerFound &= xnManufacturer.SelectSingleNode("Manufacturer").InnerText & " (id " & xnManufacturer.SelectSingleNode("Manufacturer_ID").InnerText & ")"
            Next
            If ManufacturerFound = "" Then
                LabelManufacturer.Text = "Manufacturer '" & Manufacturer.Text & "' not found."
            Else
                LabelManufacturer.Text = ManufacturerFound
            End If
        End If

Open in new window

Author

Commented:
Hi,

Thank You for the code and continuing to help me solve this new issue. I will try the code and get back to you tomorrow.

To answer your questions, the Manufacturer should be a partial string search and multiple IDs for that manufacturer can be found in the LinkSSADB file.

If Manufacturer is not found, the user should be notified and given an opportunity to enter another text or cancel the search.

V.

Author

Commented:
Hi,

I tried the code below, but it doesn't work when I enter a Manufacturer in the Textbox control. I tried entering multiple manufacturers, separated by a "," but it still didn't work.
 '************************************************************************************************
        Dim allSelectionString4 As String = ""
        If Manufacturer.Text <> "" Then
            Dim ManufacturerFound As String = ""
            For Each xnManufacturer As Xml.XmlNode In xdManufacturer.SelectNodes("/Root/ManufacturerTable[contains(Manufacturer, '" & Manufacturer.Text & "')]")
                If allSelectionString4 <> "" Then allSelectionString4 &= " or "
                allSelectionString4 &= "contains(concat(',', Manufacturer_ID, ','), '," & xnManufacturer.SelectSingleNode("Manufacturer_ID").InnerText & ",')"
                ' allSelectionString4 &= "contains(concat(Manufacturer_ID), '," & xnManufacturer.SelectSingleNode("Manufacturer_ID").InnerText & ",')"
                If ManufacturerFound <> "" Then ManufacturerFound &= ", "
                ManufacturerFound &= xnManufacturer.SelectSingleNode("Manufacturer").InnerText & " (id " & xnManufacturer.SelectSingleNode("Manufacturer_ID").InnerText & ")"
            Next
            If ManufacturerFound = "" Then
                Label14.Text = "Manufacturer '" & Manufacturer.Text & "' not found."
            Else
                Label14.Text = ManufacturerFound
            End If
        End If
        ' MsgBox(allSelectionString4)
        '**************************************************************************************************
Robert SchuttSoftware Engineer

Commented:
Entering multiple manufacturers won't work with this code, you would need to use a split and for loop construction for that to work.

The code looks good, can you post (a little piece of) your Manufacturer.xml file please?

Do you need case-insensitive matching? In that case use:

For Each xnManufacturer As Xml.XmlNode In xdManufacturer.SelectNodes("/Root/ManufacturerTable[contains(translate(Manufacturer, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz'), '" & Manufacturer.Text.ToLower & "')]")

Open in new window


Also, for asking the user what to do when no manufacturer matches, you could use something like this:

If ManufacturerFound = "" Then
  If MsgBox("Manufacturer '" & Manufacturer.Text & "' not found, show results disregarding this?", vbYesNo) = vbNo Then Exit Sub
  LabelManufacturer.Text = "Manufacturer '" & Manufacturer.Text & "' not found."
Else
  LabelManufacturer.Text = ManufacturerFound
End If

Open in new window


One other important thing: I've seen in an earlier post that sometimes you have spaces in the xml, for example: "<Manufacturer_ID> 1,4,6</Manufacturer_ID>". That could spoil matching. Maybe it was just in the post, not in your actual xml, but I think it's good to check. Or build something in the code to match regardless of spaces.

Author

Commented:
Hi,

Thanks for the code, I will double check the format of my strings. Below is an example of the format of my xml file. I think its probably better not to make it case sensitive.

<Root>
  <ManufacturerTable>
    <Manufacturer_ID>1</Manufacturer_ID>
    <Manufacturer>IBM</Manufacturer>
  </ManufacturerTable>
 <ManufacturerTable>
    <Manufacturer_ID>2</Manufacturer_ID>
    <Manufacturer>ARCO</Manufacturer>
  </ManufacturerTable>
</Root>
Robert SchuttSoftware Engineer

Commented:
> I think its probably better not to make it case sensitive.

Ok, so you've already got the code for that in my previous post.

The xml seems fine so if it still doesn't work, please use a breakpoint and/or other debugging tools to establish exactly what part doesn't work.

Author

Commented:
Ok, I will run some more test and get back toy you. Thanks.

Author

Commented:
Hi,

I think the problem is in the part of the code below because  "allSelectionString4"  keeps returning a blank value, any ideas what is causing this problem? I am only entering a single value in the textbox.

If allSelectionString4 <> "" Then allSelectionString4 &= " or "
                allSelectionString4 &= "contains(concat(',', Manufacturer_ID, ','), '," & xnManufacturer.SelectSingleNode("Manufacturer_ID").InnerText & ",')"
Robert SchuttSoftware Engineer

Commented:
Well then I would actually expect the problem to be on the line before: "For Each xnManufacturer ...", can you put a breakpoint on that and first establish that it is reached and what the content of the SelectNodes is, by putting a watch on the whole expression?

See attached image for an example of how it looks with me. This is assuming you already checked the content of the text field.
EE-Q-27675613-debugging-new.png

Author

Commented:
Hi,

I am getting the following error message:

XpathException was unhandled by user code (Heading)
Expression must evaluate to a node-set (Error message)

On Line:
Dim selectedNodes As Xml.XmlNodeList = xdlink.SelectNodes("/Root/LinkA[" & allSelectionStringOverall & "]")


All i did differently was add another View in my MultiView control to see the results of my search, not sure if the error is cause because the page load event is triggered when I go the other other view to see my results.

I  put  a message box right below the code:

For Each xnManufacturer As Xml.XmlNode In xdManufacturer.SelectNodes("/Root/ManufacturerTable[contains(Manufacturer, '" & Manufacturer.Text & "')]")
Msgbox "Test"

But I am unable to execute the code because of this new error, any ideas what is causing this problem?

Victor

Author

Commented:
Something in my form load event is causing this error because when I stay on the same view using code A it is working ok.

A -  ViewState("CurrentRecord") = 1
        UpdateGrid()
        MultiView1.ActiveViewIndex = 0

But when I tgo to the next view to see the results using the code B,  the Controls don't show the sesults and when I click on Next to try to see the results for the next record, then the error occurs.

B - ViewState("CurrentRecord") = 1
        UpdateGrid()
        MultiView1.ActiveViewIndex = 1

Not sure if my explantion helps you understand better, but please let me know if you have any questions.

Thanks,

V.

Author

Commented:
Hi,

Some progress. I am able to see the first record of my results in the next View with the code below, but still next the same error when I try top move to the next record.

ViewState("CurrentRecord") = 1
 UpdateGrid()
  MultiView1.ActiveViewIndex = 1

V.

Author

Commented:
Regarding issue with the Manufacturer.Text, you are right, the Msgbox "Test" does not execute below the code below, something is wrong with that line, running some test to see what is wrong.
 
For Each xnManufacturer As Xml.XmlNode In xdManufacturer.SelectNodes("/Root/ManufacturerTable[contains(Manufacturer, '" & Manufacturer.Text & "')]")
Msgbox "Test"

Author

Commented:
Hi,

when I click on the Next button for the next record, the error occurs because "allSelectionStringOverall" is blank. The search was trigered from View 0, but the next button is clicked on while I am in View 1, for some reason the values selected while in View 0 no longer exist. Any ideas how to fix this problem?

Author

Commented:
For example when I click on the Next button,  MsgBox("Value") in the code below doesn't execute. Like it did when I clicked on the Search button while in View 0.


 Dim allSelectionString1 As String = ""
        For itemCounter As Integer = 0 To C1ACountryUser.Items.Count - 1
            If C1ACountryUser.Items(itemCounter).Selected Then
                MsgBox("Value")
                If allSelectionString1 <> "" Then allSelectionString1 &= " or "
                allSelectionString1 &= "contains(concat(',', CountryUser_ID, ','), '," & C1ACountryUser.Items(itemCounter).Value & ",')"
            End If
        Next
Robert SchuttSoftware Engineer

Commented:
Hmm, I'm afraid I don't really know what the influence of the MultiView could be.

But if you set ViewState("CurrentRecord") = 1 then that's the reason you don't go to 'record 2' because that's exactly what's being used to determine which record to show.

So only set that in the Page_Load the first time, like I posted earlier:

    Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
        If Not IsPostBack Then ' first time
            ViewState("CurrentRecord") = 1
            UpdateGrid()
        End If
    End Sub

Open in new window

Author

Commented:
Just tried your suggestion, but still the same error, for some reason

If C1ACountryUser.Items(itemCounter).Selected Then

doesn't execute when I click on next, perhaps when you are in another view the controls in a previous view is not recognized?, Will keep running more test.

Thanks.
Robert SchuttSoftware Engineer

Commented:
Can you post your html (aspx) please?

Author

Commented:
Hi,

Below is my .aspx page, removed a lot of unecessary information, tried the same test and getting the same problem, I hope you can replicate it from your end, will post the aspx.vb code shortly. Thanks.




1. ASPX

<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Amend.aspx.vb" Inherits="AOP8Webprototype.Amend" %>
<%@ Register assembly="C1.Web.UI.Controls.4" namespace="C1.Web.UI.Controls.C1ComboBox" tagprefix="cc1" %>
<%@ Register assembly="C1.Web.UI.Controls.4" namespace="C1.Web.UI.Controls.C1Input" tagprefix="cc2" %>
<%@ Register assembly="C1.Web.UI.Controls.4" namespace="C1.Web.UI.Controls.C1GridView" tagprefix="cc1" %>
<%@ Register assembly="C1.Web.UI.Controls.4" namespace="C1.Web.UI.Controls.C1Input" tagprefix="cc3" %>
<%@ Register assembly="C1.Web.UI.Controls.4" namespace="C1.Web.UI.Controls.C1Calendar" tagprefix="cc4" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>AOP-8 Prototype</title>
    <style type="text/css">
               .mainTable { margin: auto;
                height:1500;border:solid 2px black;width:1120px;
            background-color: Silver
        }
        .insideTD2 { padding:10px }
               
       
         .center1
         {
            margin-left: auto;
   margin-right: auto;
 width:600;
         }
            </style>
</head>


<body id="Body1" class="style800" runat="server">
    <form id="form1" runat="server">
     <asp:ScriptManager ID="ScriptManager1" runat="server" />
      <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate runat="server">
    <div "margin-left:auto; margin-right: auto; margin-Bottom:auto; margin-Top:auto;">  
   
         <table cellpadding="0" cellspacing="0" class="mainTable" bgcolor="Silver" "margin-Bottom:auto; margin-Top:auto; margin-left:auto; margin-right: auto;">
             <tr>
                 <td colspan="8" style="text-align: center; font-weight: 700">
                     <h2 class="style1027">
                         &nbsp;</h2>
                 </td>
             </tr>
             <tr>
                 <td class="style1114">
                     <asp:RadioButton ID="RadioButton6" runat="server" Width="93px" AutoPostBack="True"
                         Checked="True" style="text-align: left" Text="Temporary" />
                 </td>
                 <td class="style1114">
                     <asp:RadioButton ID="RadioButton7" runat="server" AutoPostBack="True"
                         Text="Permanent" Enabled="False" />
                 </td>
                 <td class="style1100" style="text-align: right">
                     Username</td>
                 <td class="style1114">
                     <asp:TextBox ID="Username" runat="server" Width="120px"></asp:TextBox>
                 </td>
                 <td class="style1094" colspan="2">
                     &nbsp;</td>
                 <td class="style1037">
                     <asp:Button ID="Button173" runat="server" Text="Search" Width="81px"
                         Height="26px" />
                     <asp:Button ID="Previous" runat="server" Text="Previous" />
                     <asp:Button ID="NextA" runat="server" Text="Next" />
                     <asp:Label ID="Label15" runat="server" Text="Label"></asp:Label>
                     <asp:Label ID="Label14" runat="server" Text="Label"></asp:Label>
                 </td>
                 <td class="style1097">
                     <asp:Button ID="Button138" runat="server" Height="25px" Text="Log In"
                         Width="87px" />
                     <asp:Button ID="Button139" runat="server" Text="Log Out" Width="68px" />
                     <asp:Button ID="Button140" runat="server" ForeColor="Red" Text="Exit" OnClientClick="closeWindow"
                         Width="50px"/></td>
             </tr>
             </td>
             <tr style="text-align: left">
                 <td class="style1114">
                     <asp:RadioButton ID="RadioButton2" runat="server" AutoPostBack="True"
                         BorderColor="#666666" BorderStyle="None" Font-Bold="True"
                         ForeColor="#FFFF66" Text="Add/Update" style="color: #333333"
                         Checked="True" />
                     </td>
                     <td class="style1109">
                     <asp:RadioButton ID="RadioButton3" runat="server" BorderColor="#666666"
                         BorderStyle="None" Text="Search" AutoPostBack="True" />
                    </td>
                 <td class="style1100">
                     Password</td>
                 <td>
                     <asp:TextBox ID="Password" runat="server"
                         style="margin-right: 0px; text-align: left;" TextMode="Password" Width="120px"></asp:TextBox>
                 </td>
                         <td class="style1115">
                             &nbsp;</td>
                         <td colspan="2" align = "right" valign="top">
                             <asp:Label ID="Label12" runat="server" BackColor="Silver"
                                 BorderColor="#3333FF" ForeColor="Black" Height="23px">Screen  </asp:Label>
                             <asp:Label ID="Label11" runat="server" BackColor="Silver" BorderColor="#3333FF"
                                 ForeColor="Black" Height="23px" Width="16px">1</asp:Label>
                             <asp:Label ID="label10S" runat="server" BackColor="Silver" ForeColor="Black"
                                 Text="of   " Height="23px" Width="15px"></asp:Label>
                             <asp:Label ID="Label9S" runat="server" BackColor="Silver" ForeColor="Black"
                                 BorderColor="Silver" Height="23px" Width="15px">9</asp:Label>
                             <asp:Button ID="btnFirst" runat="server" style="text-align: justify"
                                 Text="|&lt;&lt; " Width="35px" />
                             <asp:Button ID="btnBack" runat="server" Height="25px" Text="&lt;&lt;  "
                                 Width="35px" />
                             <asp:Button ID="btnNext" runat="server" Height="25px" Text="&gt;&gt; " 
                                 Width="35px" />
                                 <asp:Button ID="btnLast" runat="server" style="margin-left: 0px"
                                 Text="&gt;&gt;|" Width="30px" />
                 </td>
                 <td class="style1097">
                     <cc1:C1ComboBox ID="C1ScreenA" runat="server" AppendDataBoundItems="True"
                         AutoComplete="False" AutoPostBack="True" BackColor="#FFFF99"
                         DropDownPositioningMode="Absolute" DropDownResizable="True" Height="20px"
                         MaxLength="35" style="text-align: left" Text="Select Screen"
                         UseEmbeddedVisualStyles="True" VisualStyle="Office2007Blue" Width="263px"
                         DropDownBackColor="Yellow">
                     </cc1:C1ComboBox>
                 </td>
             </tr>
         </table>
     </div>
         <asp:MultiView ID="MultiView1" runat="server" ActiveViewIndex="0">
         <asp:View ID="View1" runat="server">
             <div>
         
                 <table class="style1418">
                     <tr>
                         <td class="style1420">
                             <asp:Button ID="Button172" runat="server" Text="+" Width="25px" />
                         </td>
                         <td class="style1423">
                             </td>
                         <td class="style1424">
                           
                         </td>
                         
                     </tr>
                     <tr>
                         <td class="style1420">
                             <asp:Button ID="Button174" runat="server" Text="+" Width="25px" />
                         </td>
                         
                         
                         <td>
                             &nbsp;</td>
                         <td>
                             &nbsp;</td>
                         <td>
                             &nbsp;</td>
                     </tr>
                     <tr>
                         <td class="style1420">
                             <asp:Button ID="Button175" runat="server" Text="+" Width="25px" />
                         </td>
                         <td class="style1423">
                             Manufacturer</td>
                         <td class="style1424">
                             <cc1:C1ComboBox ID="C1AManufacturer" runat="server"
                                 DropDownPositioningMode="TopRight" SelectionMode="Multiple">
                             </cc1:C1ComboBox>
                         </td>
                     </tr>
                     <tr>
                         <td class="style1420">
                             <asp:Button ID="Button176" runat="server" Text="+" Width="25px" />
                         </td>
                         
                             <caption>
                                 &nbsp;</td>
                                 <td>
                                     &nbsp;</td>
                                 <td>
                                     &nbsp;</td>
                         </caption>
                     </tr>
                     <tr>
                         <td class="style1420">
                             <asp:Button ID="Button177" runat="server" Text="+" Width="25px" />
                         </td>
                         <td class="style1423">
                             Country-Origin</td>
                         <td class="style1424">
                             <cc1:C1ComboBox ID="C1ACountryOrigin" runat="server"
                                 DropDownPositioningMode="TopRight" SelectionMode="Multiple">
                             </cc1:C1ComboBox>
                         </td>
                         <td>
                             &nbsp;</td>
                         <td>
                             &nbsp;</td>
                         <td>
                             &nbsp;</td>
                     </tr>
                     <tr>
                         <td class="style1420">
                             <asp:Button ID="Button178" runat="server" Text="+" Width="25px" />
                         </td>
                         <td class="style1423">
                             Country_User</td>
                         <td class="style1424">
                             <cc1:C1ComboBox ID="C1ACountryUser" runat="server"
                                 DropDownPositioningMode="TopRight" SelectionMode="Multiple">
                             </cc1:C1ComboBox>
                         </td>
                         <td>
                             </td>
                         <td>
                             </td>
                         <td>
                             </td>
                     </tr>
                     <tr>
                         <td class="style1420">
                             <asp:Button ID="Button179" runat="server" Text="+" Width="25px" />
                         </td>
                       
                     </tr>
                     
                 </table>
         
             </div>
             </asp:View>
            <asp:View ID="View2" runat="server">
            <div>
     
        <table class="center1" bgcolor="Silver">
           <tr>
               <td class="style1171">
                      <asp:Panel ID="Panel5" runat="server" Width="550px" BorderStyle="Solid"
                          Height="608px">
                            <table border="1">
                            <tr>
                             <td class="style988" colspan="3"bgcolor="Yellow" align = "center">
                                 &nbsp;</td>
                           </tr>
                     <tr>
                     <td class="style1244" bgcolor="Silver">
                         <span class="style990"><br />
                        </span></td>
                    <td bgcolor="Silver" class="style1245" valign="top">
                        &nbsp;</td>
                 
                    <td class="style1246" bgcolor="Silver" valign="top">
                        <asp:Button ID="Button3" runat="server" Text="?" Width="26px" />
                    </td>
                        </tr>
                        <tr>
                        <td class="style1274" bgcolor="Silver">
                     101-Manufacturer<br /> (Max 50 characters)<br />
                     <br />
                 </td>
                 <td bgcolor="Silver" class="style1271">
                     <asp:TextBox ID="C1Manufacturer" type="text" runat="server" Width="328px" Height="47px"
                         MaxLength="50" BackColor="White" Autopostback = "False"
                         TextMode="MultiLine" style="overflow:hidden" MyMaxLength="35"></asp:TextBox>
                 </td>
                 <td class="style1178" bgcolor="Silver">
                    <asp:Button ID="Button38" runat="server" Text="?" Width="26px" />
                     <br />
                     <br />
                 </td>
                        </tr>
                        <tr>
                        <td class="style1230" bgcolor="Silver" valign="top">
                            <br />
                     </td>
                 <td bgcolor="Silver" class="style1231" valign="top">
                     &nbsp;</td>
                <td bgcolor="Silver" valign="top" class="style1232">
                    &nbsp;</td>
                       
                        </tr>


                        <tr>
                        <td class="style1254" bgcolor="Silver" valign="top">
                            <br />
                   </td>
                 <td bgcolor="Silver" class="style1237" valign="top">
                     <br />
                     <br />
                     <br />
                </td>
                <td class="style1247" bgcolor="Silver" valign="top">
                   
                             <br />
                    <br />
                   
                             </td>
                        </tr>

                        <tr>
                       
                        <td class="style1255" bgcolor="Silver" align="justify" valign="top">
                            &nbsp;</td>
                <td bgcolor="Silver" align="justify" class="style1209" valign="top">
                        <br />
                    <br />
                    <br />
                     <br />
                   
                  </td>
               
                 <td class="style1252" bgcolor="Silver" align="justify" valign="top">
                     <br />
                     <br />
                     <br />
                     <br />
                     <br />
                     </td>
                       
                        </tr>

                        <tr>
                       
                        <td class="style1399" bgcolor="Silver" valign="top">
                            &nbsp;</td>
                        <td bgcolor="Silver" class="style1400" valign="top">
                            &nbsp;</td>
                         <td bgcolor="Silver" class="style1401" valign="top">
                       
                             &nbsp;</tr>

                        <tr>
                       
                        <td bgcolor="Silver" class="style1249" valign="top">
                            <br />
                    </td>
                    <td bgcolor="Silver" class="style1250">
                        &nbsp;&nbsp;<br />
                        <br />
                    </td>
                    <td bgcolor="Silver" class="style1251">
                        <br />
                        <br />
                        <br />
                    </td>
                       
                        </tr>
                     </table>
                            <br />
                 </asp:Panel>  
                 </td>
                       <td class="style1191">
                            <asp:Panel ID="Panel11" runat="server" Width="550px" BorderStyle="Solid"
                          Height="608px">
                            <table border="1" style="height: 456px">
                     <tr>
                             <td class="style988" colspan="3" bgcolor="Yellow" align = "center">
                                 &nbsp;</td>
                     </tr>
                      <tr>
                      <td class="style1279" bgcolor="Silver" style="1018">
                        200-Country of Origin<span class="style990"> (*)<br />
                          </span>
                          </td>
                    <td class="style1280" bgcolor="Silver" valign="top">
                        <cc1:C1ComboBox ID="C1CountryOrigin" runat="server" AutoPostBack="True"
                            DropDownPositioningMode="BottomCenter"
                            ForceSelectionText="True" Height="32px" IsEditable="False"
                            style="text-align: left"
                            Width="60px" Text="Select" OpenDropDownOnLoad="True">
                        </cc1:C1ComboBox>
                    </td>
                    <td bgcolor="Silver" class="style1281" valign="top">
                            &nbsp;</td>
                      </tr>
                      <tr>
                      <td class="style1282" bgcolor="Silver">
                          210-User Country <br />
                          &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Login Country</td>
                 <td bgcolor="Silver" valign="top" class="style1283">
                     <cc1:C1ComboBox ID="C1CountryUserA" runat="server" Width="60px"
                         BackColor="#CC6699"
                         DropDownPositioningMode="RightTop"
                         IsEditable="False" ShowTrigger="False" AppendDataBoundItems="True"
                         AutoComplete="False" DropDownResizable="True" MaxLength="35"
                         OpenDropDownOnLoad="True">
                              </cc1:C1ComboBox>
                 </td>
         
                  <td bgcolor="Silver" class="style1281" valign="top">
                      &nbsp;</td>
                      </tr>
                      <tr>
                      <td class="style1288" bgcolor="Silver">
                          &nbsp;</td>
                 <td bgcolor="Silver" valign="top" class="style1289">
                     &nbsp;</td>
                 <td class="style1281" bgcolor="Silver">
                     &nbsp;</td>
                      </tr>
                      <tr>
                      <td class="style1276" bgcolor="Silver" style="1018" valign="top">
                          &nbsp;</td>
                  <td bgcolor="Silver" style="1018" valign="top" class="style1291">
                      &nbsp;</td>
                 
                     <td class="style68" bgcolor="Silver">
                         &nbsp;</td>
                     
                      </tr>

                      <tr>
                      <td class="style1285" bgcolor="Silver" align="left" valign="top">
                          <br /> <br /> <br /> &nbsp;&nbsp;&nbsp;
                          <br />
                    <br />
                    <br />
                          <br />
                 </td>
                 <td bgcolor="Silver" align="left" valign="top" class="style1286">
                     <br />
                     <br />
                     <br />
                     <br />
                     <br />
                     <br />
                     <br />
                     <br />
                     <br />
                     <br />
                 </td>
                 <td class="style1388" align="justify" bgcolor="Silver" valign="top">
                     <br />
                     <br />
                 </td>
                      </tr>
                          </tr>
                          </table>
                           </asp:Panel>
                          </td>
                    </tr>
                </table>
           </div>
             </asp:View>
        </asp:MultiView>
           <table cellpadding="0" cellspacing="0" class="mainTable">
        <tr>
         <td class="style1103">
             &nbsp;</td>
            <td class="style122">
                &nbsp;</td>
            <td class="style122">
                &nbsp;</td>
            <td class="style1121">
                &nbsp;</td>
            <td class="style122" valign="top">
                &nbsp;</td>
            <td class="style122">
                &nbsp;</td>
       </tr>
       </table>
       </ContentTemplate>
   </asp:UpdatePanel>
    </form>
</body>
</html>

Author

Commented:
Hi,

This version has less unnecessary code:


<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Amend.aspx.vb" Inherits="AOP8Webprototype.Amend" %>
<%@ Register assembly="C1.Web.UI.Controls.4" namespace="C1.Web.UI.Controls.C1ComboBox" tagprefix="cc1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
</head>
<body id="Body1" class="style800" runat="server">
    <form id="form1" runat="server">
     <asp:ScriptManager ID="ScriptManager1" runat="server" />
      <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate runat="server">
    <div "margin-left:auto; margin-right: auto; margin-Bottom:auto; margin-Top:auto;">  
   
         <table cellpadding="0" cellspacing="0" class="mainTable" bgcolor="Silver" "margin-Bottom:auto; margin-Top:auto; margin-left:auto; margin-right: auto;">
             <tr>
                 <td colspan="8" style="text-align: center; font-weight: 700">
                     <h2 class="style1027">
                         &nbsp;</h2>
                 </td>
             </tr>
             <tr>
               
                 <td class="style1037">
                     <asp:Button ID="Button173" runat="server" Text="Search" Width="81px"
                         Height="26px" />
                     <asp:Button ID="Previous" runat="server" Text="Previous" />
                     <asp:Button ID="NextA" runat="server" Text="Next" />
                     <asp:Label ID="Label15" runat="server" Text="Label"></asp:Label>
                     <asp:Label ID="Label14" runat="server" Text="Label"></asp:Label>
                 </td>
         
             </tr>
             </td>
             <tr style="text-align: left">
                 <td class="style1114">
                     <asp:RadioButton ID="RadioButton2" runat="server" AutoPostBack="True"
                         BorderColor="#666666" BorderStyle="None" Font-Bold="True"
                         ForeColor="#FFFF66" Text="Add/Update" style="color: #333333"
                         Checked="True" />
                     </td>
                     <td class="style1109">
                     <asp:RadioButton ID="RadioButton3" runat="server" BorderColor="#666666"
                         BorderStyle="None" Text="Search" AutoPostBack="True" />
                    </td>
                 <td class="style1100">
                     Password</td>
                 <td>
                     <asp:TextBox ID="Password" runat="server"
                         style="margin-right: 0px; text-align: left;" TextMode="Password" Width="120px"></asp:TextBox>
                 </td>
                         <td class="style1115">
                             &nbsp;</td>
                         <td colspan="2" align = "right" valign="top">
                             <asp:Label ID="Label12" runat="server" BackColor="Silver"
                                 BorderColor="#3333FF" ForeColor="Black" Height="23px">Screen  </asp:Label>
                             <asp:Label ID="Label11" runat="server" BackColor="Silver" BorderColor="#3333FF"
                                 ForeColor="Black" Height="23px" Width="16px">1</asp:Label>
                             <asp:Label ID="label10S" runat="server" BackColor="Silver" ForeColor="Black"
                                 Text="of   " Height="23px" Width="15px"></asp:Label>
                             <asp:Label ID="Label9S" runat="server" BackColor="Silver" ForeColor="Black"
                                 BorderColor="Silver" Height="23px" Width="15px">9</asp:Label>
                             <asp:Button ID="btnFirst" runat="server" style="text-align: justify"
                                 Text="|&lt;&lt; " Width="35px" />
                             <asp:Button ID="btnBack" runat="server" Height="25px" Text="&lt;&lt;  "
                                 Width="35px" />
                             <asp:Button ID="btnNext" runat="server" Height="25px" Text="&gt;&gt; " 
                                 Width="35px" />
                                 <asp:Button ID="btnLast" runat="server" style="margin-left: 0px"
                                 Text="&gt;&gt;|" Width="30px" />
                 </td>
                 <td class="style1097">
                     <cc1:C1ComboBox ID="C1ScreenA" runat="server" AppendDataBoundItems="True"
                         AutoComplete="False" AutoPostBack="True" BackColor="#FFFF99"
                         DropDownPositioningMode="Absolute" DropDownResizable="True" Height="20px"
                         MaxLength="35" style="text-align: left" Text="Select Screen"
                         UseEmbeddedVisualStyles="True" VisualStyle="Office2007Blue" Width="263px"
                         DropDownBackColor="Yellow">
                     </cc1:C1ComboBox>
                 </td>
             </tr>
         </table>
     </div>
         <asp:MultiView ID="MultiView1" runat="server" ActiveViewIndex="0">
         <asp:View ID="View1" runat="server">
             <div>
         
                 <table class="style1418">
                     <tr>
                         <td class="style1420">
                             <asp:Button ID="Button172" runat="server" Text="+" Width="25px" />
                         </td>
                         <td class="style1423">
                             </td>
                         <td class="style1424">
                           
                         </td>
                         
                     </tr>
                     <tr>
                         <td class="style1420">
                             <asp:Button ID="Button174" runat="server" Text="+" Width="25px" />
                         </td>
                         
                         
                     </tr>
                     <tr>
                         <td class="style1420">
                             <asp:Button ID="Button175" runat="server" Text="+" Width="25px" />
                         </td>
                         <td class="style1423">
                             Manufacturer</td>
                         <td class="style1424">
                             <cc1:C1ComboBox ID="C1AManufacturer" runat="server"
                                 DropDownPositioningMode="TopRight" SelectionMode="Multiple">
                             </cc1:C1ComboBox>
                         </td>
                     </tr>
                     <tr>
                         <td class="style1420">
                             <asp:Button ID="Button176" runat="server" Text="+" Width="25px" />
                         </td>
                         
                             
                     </tr>
                     <tr>
                         <td class="style1420">
                             <asp:Button ID="Button177" runat="server" Text="+" Width="25px" />
                         </td>
                         <td class="style1423">
                             Country-Origin</td>
                         <td class="style1424">
                             <cc1:C1ComboBox ID="C1ACountryOrigin" runat="server"
                                 DropDownPositioningMode="TopRight" SelectionMode="Multiple">
                             </cc1:C1ComboBox>
                         </td>
                         <td>
                             &nbsp;</td>
                         <td>
                             &nbsp;</td>
                         <td>
                             &nbsp;</td>
                     </tr>
                     <tr>
                         <td class="style1420">
                             <asp:Button ID="Button178" runat="server" Text="+" Width="25px" />
                         </td>
                         <td class="style1423">
                             Country_User</td>
                         <td class="style1424">
                             <cc1:C1ComboBox ID="C1ACountryUser" runat="server"
                                 DropDownPositioningMode="TopRight" SelectionMode="Multiple">
                             </cc1:C1ComboBox>
                         </td>
                     </tr>
                     <tr>
                         <td class="style1420">
                             <asp:Button ID="Button179" runat="server" Text="+" Width="25px" />
                         </td>
                       
                     </tr>
                     
                 </table>
         
             </div>
             </asp:View>
            <asp:View ID="View2" runat="server">
            <div>
     
        <table class="center1" bgcolor="Silver">
           <tr>
               <td class="style1171">
                      <asp:Panel ID="Panel5" runat="server" Width="550px" BorderStyle="Solid"
                          Height="608px">
                            <table border="1">
                            <tr>
                             <td class="style988" colspan="3"bgcolor="Yellow" align = "center">
                                 &nbsp;</td>
                           </tr>
                     <tr>
                     <td class="style1244" bgcolor="Silver">
                         <span class="style990"><br />
                        </span></td>
                    <td bgcolor="Silver" class="style1245" valign="top">
                        &nbsp;</td>
                 
                    <td class="style1246" bgcolor="Silver" valign="top">
                        <asp:Button ID="Button3" runat="server" Text="?" Width="26px" />
                    </td>
                        </tr>
                        <tr>
                        <td class="style1274" bgcolor="Silver">
                     101-Manufacturer<br /> (Max 50 characters)<br />
                     <br />
                 </td>
                 <td bgcolor="Silver" class="style1271">
                     <asp:TextBox ID="C1Manufacturer" type="text" runat="server" Width="328px" Height="47px"
                         MaxLength="50" BackColor="White" Autopostback = "False"
                         TextMode="MultiLine" style="overflow:hidden" MyMaxLength="35"></asp:TextBox>
                 </td>
                 <td class="style1178" bgcolor="Silver">
                    <asp:Button ID="Button38" runat="server" Text="?" Width="26px" />
                     <br />
                     <br />
                 </td>
                        </tr>
                        <tr>
                        <td class="style1230" bgcolor="Silver" valign="top">
                            <br />
                     </td>
                 <td bgcolor="Silver" class="style1231" valign="top">
                     &nbsp;</td>
                <td bgcolor="Silver" valign="top" class="style1232">
                    &nbsp;</td>
                       
                        </tr>


                        <tr>
                        <td class="style1254" bgcolor="Silver" valign="top">
                            <br />
                   </td>
               
                     </table>
                            <br />
                 </asp:Panel>  
                 </td>
                       <td class="style1191">
                            <asp:Panel ID="Panel11" runat="server" Width="550px" BorderStyle="Solid"
                          Height="608px">
                            <table border="1" style="height: 456px">
                     <tr>
                             <td class="style988" colspan="3" bgcolor="Yellow" align = "center">
                                 &nbsp;</td>
                     </tr>
                      <tr>
                      <td class="style1279" bgcolor="Silver" style="1018">
                        200-Country of Origin<span class="style990"> (*)<br />
                          </span>
                          </td>
                    <td class="style1280" bgcolor="Silver" valign="top">
                        <cc1:C1ComboBox ID="C1CountryOrigin" runat="server" AutoPostBack="True"
                            DropDownPositioningMode="BottomCenter"
                            ForceSelectionText="True" Height="32px" IsEditable="False"
                            style="text-align: left"
                            Width="60px" Text="Select" OpenDropDownOnLoad="True">
                        </cc1:C1ComboBox>
                    </td>
                    <td bgcolor="Silver" class="style1281" valign="top">
                            &nbsp;</td>
                      </tr>
                      <tr>
                      <td class="style1282" bgcolor="Silver">
                          210-User Country <br />
                          &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Login Country</td>
                 <td bgcolor="Silver" valign="top" class="style1283">
                     <cc1:C1ComboBox ID="C1CountryUserA" runat="server" Width="60px"
                         BackColor="#CC6699"
                         DropDownPositioningMode="RightTop"
                         IsEditable="False" ShowTrigger="False" AppendDataBoundItems="True"
                         AutoComplete="False" DropDownResizable="True" MaxLength="35"
                         OpenDropDownOnLoad="True">
                              </cc1:C1ComboBox>
                 </td>
         
                  <td bgcolor="Silver" class="style1281" valign="top">
                      &nbsp;</td>
                      </tr>
                      <tr>
                      <td class="style1288" bgcolor="Silver">
                          &nbsp;</td>
                 <td bgcolor="Silver" valign="top" class="style1289">
                     &nbsp;</td>
                 <td class="style1281" bgcolor="Silver">
                     &nbsp;</td>
                      </tr>
                      <tr>
                      <td class="style1276" bgcolor="Silver" style="1018" valign="top">
                          &nbsp;</td>
                  <td bgcolor="Silver" style="1018" valign="top" class="style1291">
                      &nbsp;</td>
                 
                     <td class="style68" bgcolor="Silver">
                         &nbsp;</td>
                     
                      </tr>

                      <tr>
                     
                      </tr>
                          </tr>
                          </table>
                           </asp:Panel>
                          </td>
                    </tr>
                </table>
           </div>
             </asp:View>
        </asp:MultiView>
           <table cellpadding="0" cellspacing="0" class="mainTable">
       </table>
       </ContentTemplate>
   </asp:UpdatePanel>
    </form>
</body>
</html>

Author

Commented:
Hi,

Below is the aspx.vb file. Button 173 triggers the search,  Further below is an example of the LinkSSADB file.

Imports System.Xml
Imports System
Imports System.Text
Imports C1.Web.UI.Controls.C1ComboBox
Imports C1.Web.UI.Controls.C1Input
Public Class Amend
    Inherits System.Web.UI.Page
    Public text As String
    Public num As Integer
    Public docName As String
    Public CurrentIndex As Integer
    Public dtTable As DataTable
    Dim dtDonor As DataTable
    Dim dtReceiver As DataTable
    Dim dtLinkID As DataTable
    Dim dtManufacturer As DataTable
     Dim dtLink As DataTable
    Dim currentIndemmo As Integer
    Dim NodeNumber As Integer = 0
    Dim xnLink As New XmlDocument()
    Dim xnLinkA As New XmlDocument()
    Public LinkID2 As String


       

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not IsPostBack Then ' first time
            ViewState("CurrentRecord") = 1
            UpdateGrid()

            RadioButton2.Checked = False
            Dim CountryUser As New DataSet
            CountryUser.ReadXml(Server.MapPath("~/App_Data/CountryUser.xml"))
            C1ACountryUser.DataSource = CountryUser.Tables(0)
            C1ACountryUser.DataMember = "CountryUser"
            C1ACountryUser.DataTextField = "CountryUser"
            C1ACountryUser.DataValueField = "CountryUser_ID"
            C1ACountryUser.DataBind()

            Dim CountryOrigin As New DataSet
            CountryOrigin.ReadXml(Server.MapPath("~/App_Data/CountryOrigin.xml"))
            C1ACountryOrigin.DataSource = CountryOrigin.Tables(0)
            C1ACountryOrigin.DataMember = "CountryOrigin"
            C1ACountryOrigin.DataTextField = "CountryOrigin"
            C1ACountryOrigin.DataValueField = "CountryOrigin_ID"
            C1ACountryOrigin.DataBind()

            Dim Manufacturer As New DataSet
            Manufacturer.ReadXml(Server.MapPath("~/App_Data/Manufacturer.xml"))
            C1AManufacturer.DataSource = Manufacturer.Tables(0)
            C1AManufacturer.DataMember = "Manufacturer"
            C1AManufacturer.DataTextField = "Manufacturer"
            C1AManufacturer.DataValueField = "Manufacturer_ID"
            C1AManufacturer.DataBind()
        End If
    End Sub

    Protected Overrides Sub OnPreRender(ByVal e As EventArgs)
        btnBack.Visible = MultiView1.ActiveViewIndex > 0
        btnNext.Visible = MultiView1.ActiveViewIndex < MultiView1.Views.Count - 1
        MyBase.OnPreRender(e)
    End Sub

 

    Protected Sub btnBack_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnBack.Click
        MultiView1.ActiveViewIndex -= 1
        Label11.Text = MultiView1.ActiveViewIndex + 1
    End Sub
   

       



   

   

 






   
   

   
 



    Protected Sub Button169_Click(sender As Object, e As EventArgs) Handles Previous.Click
        ViewState("CurrentRecord") -= 1
        UpdateGrid()
    End Sub

    Private Sub UpdateGrid()
        Dim xdManufacturer As New XmlDocument
        Dim ManufacturerID As String
        Dim ManufacturerID2 As String
        Dim astrixState As Integer
        astrixState = 0
        Dim xdlink As New Xml.XmlDocument, xdReceiver As New Xml.XmlDocument, Link_ID As String, ReceiverID As String, ReceiverID2 As String, DonorID As String, DonorID2 As String, Name As String
        xdlink.Load(Server.MapPath("LinkSSADB.xml"))
        xdReceiver.Load(Server.MapPath("CountryUser.xml"))  '1
        xdManufacturer.Load(Server.MapPath("Manufacturer.xml"))
        On Error Resume Next

        Dim allSelectionString1 As String = ""
        For itemCounter As Integer = 0 To C1ACountryUser.Items.Count - 1
            If C1ACountryUser.Items(itemCounter).Selected Then
                If allSelectionString1 <> "" Then allSelectionString1 &= " or "
                allSelectionString1 &= "contains(concat(',', CountryUser_ID, ','), '," & C1ACountryUser.Items(itemCounter).Value & ",')"
            End If
        Next


        Dim allSelectionString2 As String = ""
        For itemCounter As Integer = 0 To C1ACountryOrigin.Items.Count - 1
            If C1ACountryOrigin.Items(itemCounter).Selected Then
                If allSelectionString2 <> "" Then allSelectionString2 &= " or "
                allSelectionString2 &= "contains(concat(',', CountryOrigin_ID, ','), '," & C1ACountryOrigin.Items(itemCounter).Value & ",')"
            End If
        Next
        '  MsgBox(allSelectionString2)
        '************************************************************************************************
        ' Dim allSelectionString4 As String = ""
        'If Manufacturer.Text <> "" Then
        'Dim ManufacturerFound As String = ""
        'For Each xnManufacturer As Xml.XmlNode In xdManufacturer.SelectNodes("/Root/ManufacturerTable[contains(Manufacturer, '" & Manufacturer.Text & "')]")
        'MsgBox("UUUUUUUUUUUUU")
        'If allSelectionString4 <> "" Then allSelectionString4 &= " or "
        'allSelectionString4 &= "contains(concat(',', Manufacturer_ID, ','), '," & xnManufacturer.SelectSingleNode("Manufacturer_ID").InnerText & ",')"
        '' allSelectionString4 &= "contains(concat(Manufacturer_ID), '," & xnManufacturer.SelectSingleNode("Manufacturer_ID").InnerText & ",')"
        'If ManufacturerFound <> "" Then ManufacturerFound &= ", "
        'ManufacturerFound &= xnManufacturer.SelectSingleNode("Manufacturer").InnerText & " (id " & xnManufacturer.SelectSingleNode("Manufacturer_ID").InnerText & ")"
        'Next
        'If ManufacturerFound = "" Then
        'Label14.Text = "Manufacturer '" & Manufacturer.Text & "' not found."
        'Else
        'Label14.Text = ManufacturerFound
        'End If
        'End If
        '   MsgBox(allSelectionString4)
        '**************************************************************************************************
        Dim dtReceiver As New DataTable
        dtReceiver.Columns.Add(New DataColumn("ID"))
        dtReceiver.Columns.Add(New DataColumn("Name"))

        Dim dtDonor As New DataTable
        dtDonor.Columns.Add(New DataColumn("ID"))
        dtDonor.Columns.Add(New DataColumn("Name"))

        Dim dtManufacturer As New DataTable
        dtManufacturer.Columns.Add(New DataColumn("ID"))
        dtManufacturer.Columns.Add(New DataColumn("Name"))

        Dim iCount As Integer = 0
        '***************************************************************************
        '   Dim allSelectionStringOverall As String = "(" & allSelectionString1 & ") and (" & allSelectionString2 & ")"
        Dim allSelectionStringOverall As String = ""
        ' all the strings we found in earlier searches are now put in an array for easy handling
        'For Each selString As String In {allSelectionString1, allSelectionString2, allSelectionString3, allSelectionString4} ' add more as needed

        For Each selString As String In {allSelectionString1, allSelectionString2} ' add more as needed
            ' only process strings that are not empty other wise we get an error on "() and ()"
            If selString <> "" Then
                ' just like in the previous block of code, do not use the operator the first time
                If allSelectionStringOverall <> "" Then allSelectionStringOverall &= " and "
                ' if we want to reverse all selections then this is the position in the string we need to insert "not" so the
                ' next part will return true when it is actually false (so it does NOT contain the selected values)
                If astrixState = 1 Then allSelectionStringOverall &= "not "
                ' here the actual query is inserted within parantheses because it can contain multiple calls to 'contains()' separated by 'or' operators
                allSelectionStringOverall &= "(" & selString & ")"
            End If
        Next
        '*************************************************
        Me.Label15.Text = allSelectionStringOverall
        Previous.Enabled = False
        ' ButtonNext.Enabled = False
        MsgBox(allSelectionStringOverall)
        Dim selectedNodes As Xml.XmlNodeList = xdlink.SelectNodes("/Root/LinkA[" & allSelectionStringOverall & "]")
        ' Dim selectedNodes As Xml.XmlNodeList = xdlink.SelectNodes("/Root/LinkA[" & vbatest & "]")
        For Each xnLink As Xml.XmlNode In selectedNodes
            Link_ID = xnLink.SelectSingleNode("LinkAID").InnerText
            ReceiverID = xnLink.SelectSingleNode("CountryUser_ID").InnerText
            DonorID = xnLink.SelectSingleNode("CountryOrigin_ID").InnerText
            ManufacturerID = xnLink.SelectSingleNode("Manufacturer_ID").InnerText
            iCount += 1
            If iCount < ViewState("CurrentRecord") Then
                Previous.Enabled = True
            ElseIf iCount > ViewState("CurrentRecord") Then
                ' ButtonNext.Enabled = True
            Else
                Label14.Text = " ( " & iCount & "/ " & selectedNodes.Count & ") "
                For Each xnReceiver As Xml.XmlNode In xdReceiver.SelectNodes("/Root/CountryUserTable[contains('," & ReceiverID & ",', concat(',', CountryUser_ID, ','))]")
                    ReceiverID2 = xnReceiver.SelectSingleNode("CountryUser_ID").InnerText
                    Name = xnReceiver.SelectSingleNode("CountryUser").InnerText
                    dtReceiver.Rows.Add({ReceiverID2, Name})
                Next
                For Each xnDonor As Xml.XmlNode In xdReceiver.SelectNodes("/Root/CountryUserTable[contains('," & DonorID & ",', concat(',', CountryUser_ID, ','))]")
                    DonorID2 = xnDonor.SelectSingleNode("CountryUser_ID").InnerText
                    Name = xnDonor.SelectSingleNode("CountryUser").InnerText
                    dtDonor.Rows.Add({DonorID2, Name})
                Next
            End If

            For Each xnManufacturer As Xml.XmlNode In xdManufacturer.SelectNodes("/Root/ManufacturerTable[contains('," & ManufacturerID & ",', concat(',', Manufacturer_ID, ','))]") '5
                ManufacturerID2 = xnManufacturer.SelectSingleNode("Manufacturer_ID").InnerText
                Name = xnManufacturer.SelectSingleNode("Manufacturer").InnerText
                dtManufacturer.Rows.Add({ManufacturerID2, Name})
            Next

        Next

   
        C1CountryUserA.DataSource = dtDonor
        C1CountryUserA.DataMember = "Name"
        C1CountryUserA.DataTextField = "Name"
        C1CountryUserA.DataValueField = "ID"
        C1CountryUserA.DataBind()

        C1CountryOrigin.DataSource = dtReceiver
        C1CountryOrigin.DataMember = "Name"
        C1CountryOrigin.DataTextField = "Name"
        C1CountryOrigin.DataValueField = "ID"
        C1CountryOrigin.DataBind()

    End Sub



    Protected Sub NextA_Click(sender As Object, e As EventArgs) Handles NextA.Click
        ViewState("CurrentRecord") += 1
        UpdateGrid()

    End Sub

 


    Protected Sub Button173_Click(sender As Object, e As EventArgs) Handles Button173.Click
        UpdateGrid()
        MultiView1.ActiveViewIndex = 1
    End Sub

    Protected Sub RadioButton3_CheckedChanged(sender As Object, e As EventArgs) Handles RadioButton3.CheckedChanged
     
    End Sub
End Class


LinkSSADB.xml

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<Root>
  <LinkA>
    <LinkAID>1</LinkAID>
    <CountryUser_ID>1,6,4</CountryUser_ID>
    <CountryOrigin_ID>1,2,4</CountryOrigin_ID>
    <Manufacturer_ID>1,2</Manufacturer_ID>
  </LinkA>
  <LinkA>
    <LinkAID>2</LinkAID>
    <CountryUser_ID>1,2,3,6</CountryUser_ID>
    <CountryOrigin_ID>1,2</CountryOrigin_ID>
    <Manufacturer_ID>1,2</Manufacturer_ID>
  </LinkA>
</Root>
Robert SchuttSoftware Engineer

Commented:
Ok, I'll give it a go. I had a MultiView working in my own code but it didn't have much data other than on the first view. I'll let you know what I find asap.

Author

Commented:
OK. Thank You.

Author

Commented:
You'll notice if you select CoutryUser DEU and CounbtryOrigin CAN it will return two records, first record will show in the two Comboboxes in View1, but when you click Next, the secxond record will not show.
Robert SchuttSoftware Engineer

Commented:
Ok, had some problems getting C1 up and running (downloaded a different version I think) but it works now.

I must say your intention with the Views is not clear to me. You don't need another view to show a different record, I made that before without views. Where are the grids to show the information?

Author

Commented:
Hi,
I am showing data for one record in 9 different screens using Comboboxes,Grids for multiple entries/lines and Textboxes for single entries.  The code for the Grid and ComboBoxes are slightly different, for example no need to includede Datatextfield and DataValue Field for the Grid control. The remaining 8 screens are linked with the LinkAID for LinkSSADB.xml.

 I am not crazy about the MultiView control because I can't print the data, but it is much easier to navigate through different screens using the Multiview control. I included the tables and panels within each View, I may eventually just use them instead of the Multi-View, once I learn how to navigate through different screens using tables/Panels.

Author

Commented:
Forgot to mention, similar to the combobox, the GridView is also empty when I try to go to the next record.
Robert SchuttSoftware Engineer

Commented:
Ok, I'll focus on that for, try to find where the selections in the xml are going wrong, because displaying the comboboxes seems not to be working at all for me.

Author

Commented:
Ok, Thanks.

In case you are interested, below is the code I used in the Update feature to include the data in multiple xml files (i.e. CountryUser.xml and LinkC.xml). Basically as I loop through the Grid coontrols I search top see if the data already aready exist in the xml file, if yes, I take the existing ID, if no I save it in the xml file and create a new ID, end resuls in the LinkC.xml file for mulitle line in the Grid should be (i.e. 1,2,4,5)

 Dim xyz() As String = New String() {"Item"..............."Item50}

Fore example, "Item" can be CountryUser.


        Dim xdItem As New Xml.XmlDocument '(1)
        Dim xdItemA As New Xml.XmlDocument
        Dim xdItemB As New Xml.XmlDocument
       
        xdItem.Load(Server.MapPath("~/App_Data/Item.xml")) '(2)

        Dim searchIdCountryOrigin As String = Nothing
        Dim searchIdCountryUser As String = Nothing
        Dim searchIdNSN As String = Nothing

        Dim searchIdItemA As String
        Dim searchIdItemR As String
        Dim searchIdItemM As String

        Dim num As Integer
        Dim numx As Integer
        Dim numy As Integer
        Dim num1 As String
        Dim num2 As String

        Dim countryUser_IDA As String = Nothing
        Dim countryUser_IDB As String = Nothing
        Dim NSN_ID As String = Nothing

        Dim ItemA_ID As String
        Dim ItemR_ID As String
        Dim ItemM_ID As String
        '*****************************************LOOP Begins***************************************************8
        Dim xyz() As String = New String() {"Item"}
        For i = 0 To 1
            num1 = ""
            num2 = ""
            num = 0
            numx = 0
            numy = 0

            searchIdItemA = ""
            Dim xid As String
            Dim xtable As String
            Dim curXYZ = xyz(i)
            Dim MyFix As XDocument = XDocument.Load(Server.MapPath("~/App_Data/" & curXYZ & ".xml"))
            xid = curXYZ & "_ID"
            xtable = curXYZ & "Table"

            'Sort ID in each xml file
            Dim LargestFixID = (From el In MyFix.Descendants(curXYZ & "Table") Select CInt(el.<xid>.Value)).ToList  
            LargestFixID.Sort()
            num = (LargestFixID.Count() + 1)
           
            Dim domFix As New XmlDocument()
            domFix.Load(Server.MapPath("~/App_Data/" & curXYZ & ".xml"))
            Dim listFix As XmlNodeList = domFix.SelectNodes("//" & xtable)

            Dim CheckForItemFix = (From el In MyFix.Descendants(xtable).Elements(curXYZ) Select el.Value).ToList
            Dim u As Integer = 0
            Dim uu As Integer = 0
            '***********Looping through all controls with multiple lines*******************************************************
            'Look for data already in Item.xml
            For x As Integer = 0 To C1GridItemA.Rows.Count - 1
                If CheckForItemFix.Contains(C1GridItemA.Rows(x).Cells(0).Text) Then
                    For Each xnLink As Xml.XmlNode In xdItem.SelectNodes("/Root/ItemTable[Item='" & C1GridItemA.Rows(x).Cells(0).Text & "']")
                        ItemA_ID = xnLink.SelectSingleNode("Item_ID").InnerText
                        If ItemA_ID <> "" Then
                            CD = ItemA_ID
                            If u > 0 Then
                                num1 = num1 & "" & CD & ","
                            Else
                                num1 = CD & ","
                            End If
                            u = u + 1
                        End If
                    Next
                End If
            Next
            'Assign ID to data not already in XML file
            For x As Integer = 0 To C1GridItemA.Rows.Count - 1
                If Not CheckForItemFix.Contains(C1GridItemA.Rows(x).Cells(0).Text) Then
                    Dim xNew As XElement = New XElement(xtable)
                    xNew.Add(New XElement(xid, num))
                    xNew.Add(New XElement(curXYZ, C1GridItemA.Rows(x).Cells(0).Text))
                    MyFix.Root.Add(xNew)
                    MyFix.Save(Server.MapPath("~/App_Data/" & curXYZ & ".xml"))
                    If uu > 0 Then
                        num2 += num & ","
                    Else
                        num2 = num & ","
                    End If
                    uu = uu + 1
                    num = num + 1
                End If
            Next
            searchIdItemA = num1 & num2
             '**************************************************************************************************************
            num1 = ""
            num2 = ""
            xdItemA.Load(Server.MapPath("~/App_Data/Item.xml"))
            Dim MyFixa As XDocument = XDocument.Load(Server.MapPath("~/App_Data/" & curXYZ & ".xml"))
            Dim CheckForItemFixa = (From el In MyFixa.Descendants(xtable).Elements(curXYZ) Select el.Value).ToList
            Dim LargestFixIDA = (From el In MyFixa.Descendants(curXYZ & "Table") Select CInt(el.<xid>.Value)).ToList
            LargestFixIDA.Sort()
            numx = (LargestFixIDA.Count() + 1)

            searchIdItemR = ""
            For x As Integer = 0 To C1GridItemR.Rows.Count - 1
                'Look for data already in XML file
                If CheckForItemFixa.Contains(C1GridItemR.Rows(x).Cells(0).Text) Then
                    For Each xnLink As Xml.XmlNode In xdItemA.SelectNodes("/Root/ItemTable[Item='" & C1GridItemR.Rows(x).Cells(0).Text & "']")
                        ItemR_ID = xnLink.SelectSingleNode("Item_ID").InnerText
                        If ItemR_ID <> "" Then
                            CD = ItemR_ID
                            If u > 0 Then
                                num1 = num1 & "" & CD & ","
                            Else
                                num1 = CD & ","
                            End If
                            u = u + 1
                        End If
                    Next
                End If
            Next
            'Assign ID to data not already in XML file
            For x As Integer = 0 To C1GridItemR.Rows.Count - 1
                If Not CheckForItemFixa.Contains(C1GridItemR.Rows(x).Cells(0).Text) Then
                    Dim xNew As XElement = New XElement(xtable)
                    xNew.Add(New XElement(xid, numx))
                    xNew.Add(New XElement(curXYZ, C1GridItemR.Rows(x).Cells(0).Text))
                    MyFixa.Root.Add(xNew)
                    MyFixa.Save(Server.MapPath("~/App_Data/" & curXYZ & ".xml"))
                    If uu > 0 Then
                        num2 += numx & ","
                    Else
                        num2 = numx & ","
                    End If
                    uu = uu + 1
                    numx = numx + 1
                End If
            Next
            searchIdItemR = num1 & num2
             '********************************************************************************************************************
            xdItemB.Load(Server.MapPath("~/App_Data/Item.xml"))
            num1 = ""
            num2 = ""
            searchIdItemM = ""
            Dim MyFixb As XDocument = XDocument.Load(Server.MapPath("~/App_Data/" & curXYZ & ".xml"))
            Dim CheckForItemFixb = (From el In MyFixb.Descendants(xtable).Elements(curXYZ) Select el.Value).ToList
            Dim LargestFixIDB = (From el In MyFixb.Descendants(curXYZ & "Table") Select CInt(el.<xid>.Value)).ToList
            LargestFixIDB.Sort()
            numy = (LargestFixIDB.Count() + 1)
            For x As Integer = 0 To C1GridItemM.Rows.Count - 1
                'Look for data alraedy in XML file
                If CheckForItemFixb.Contains(C1GridItemM.Rows(x).Cells(0).Text) Then
                    For Each xnLink As Xml.XmlNode In xdItemB.SelectNodes("/Root/ItemTable[Item='" & C1GridItemM.Rows(x).Cells(0).Text & "']")
                        ItemM_ID = xnLink.SelectSingleNode("Item_ID").InnerText
                        If ItemM_ID <> "" Then
                            CD = ItemM_ID
                            If u > 0 Then
                                num1 = num1 & "" & CD & ","
                            Else
                                num1 = CD & ","
                            End If
                            u = u + 1
                        End If
                    Next
                End If
            Next
            'Assign ID to data not already in XML file
            For x As Integer = 0 To C1GridItemM.Rows.Count - 1
                If Not CheckForItemFixb.Contains(C1GridItemM.Rows(x).Cells(0).Text) Then
                    Dim xNew As XElement = New XElement(xtable)
                    xNew.Add(New XElement(xid, numy))
                    xNew.Add(New XElement(curXYZ, C1GridItemM.Rows(x).Cells(0).Text))
                    MyFixb.Root.Add(xNew)
                    MyFixb.Save(Server.MapPath("~/App_Data/" & curXYZ & ".xml"))
                    If uu > 0 Then
                        num2 += numy & ","
                    Else
                        num2 = numy & ","
                    End If
                    uu = uu + 1
                    numy = numy + 1
                End If
            Next
            searchIdItemM = num1 & num2

  Dim MyDocLinkC As XDocument = XDocument.Load(Server.MapPath("~/App_Data/LinkC.xml"))
            Dim LinkID = (From el In MyDocLinkC.Descendants("LinkA") Select CInt(el.<LinkAID>.Value)).ToList
            LinkID.Sort()
            Dim xNewLink As XElement = New XElement("LinkA")
            xNewLink.Add(New XElement("LinkAID", (LinkID.Last() + 1)))
            If i = 0 Then
                MyDocLinkC.Root.Add(New XElement("LinkA", New XElement("LinkAID", (LinkID.Last() + 1)), New XElement("ItemA_ID", searchIdItemA), New XElement("ItemR_ID", searchIdItemR), New XElement("ItemM_ID", searchIdItemM)))
                MyDocLinkC.Save(Server.MapPath("~/App_Data/LinkC.xml"))
            End If
            Exit For
        Next

Author

Commented:
Are you using the Combobox from ComponentOne?
Robert SchuttSoftware Engineer

Commented:
Yes but possibly a slightly different one, I downloaded the Controls from their website but had to change the Imports a bit...
Robert SchuttSoftware Engineer

Commented:
I was missing a lot of button actions, think I managed to

Double check the actions on prev/next etc. buttons because I got twisted results. Maybe give them all clear names like btnSearch, btnNextResult, btnPrevResult, btnNextView, btnPrevView. What I implemented earlier was "First/Last Result", while you're using "First/Last View".

I didn't see the hidden field "Current Record" in your code, I added it directly after the <Form> tag:

<asp:HiddenField ID="CurrentRecord" runat="server" ViewStateMode="Enabled" />

Open in new window


Possibly it works without it because you can make your own entries within the ViewState collection but I was getting strange results without it.

As far as I can see the code to populate the DataTables is getting called correctly. What I did for testing: place a Label to the right of the 2 comboboxes in View2, and put the ReceiverID and DonorID in it after setting those in the loop "For Each xnLink As Xml.XmlNode In selectedNodes".

Important: An earlier change was not in this code and affects working right from the start:

after filling allSelectionStringOverall in the loop "For Each selString As String ... ... ... Next" add this:
If allSelectionStringOverall <> "" Then allSelectionStringOverall = "[" & allSelectionStringOverall & "]"

Open in new window


Then remove the "[" and "]" from here:

Dim selectedNodes As Xml.XmlNodeList = xdlink.SelectNodes("/Root/LinkA" & allSelectionStringOverall)

Open in new window

Author

Commented:
Great News!! It's working, have to run to a meeting will run more test and get back to you later. THANK YOU!

Author

Commented:
Hi,

CountryOrigin is working great, but I noticed if you go back to the same record the list of the CountryUser combobox duplicates, can you please check to see what is causing that problem?

Thanks,

V.
Robert SchuttSoftware Engineer

Commented:
Well no, not really, I still haven't got anything in there, just in the labels I added...
Robert SchuttSoftware Engineer

Commented:
But it must have something to do with a DataTable not being initialized empty? Maybe it's restored from the viewstate or session. In that case try something like: "dtReceiver.Rows.Clear()".

Author

Commented:
Hi,

I can't seem to figure it out, tried dtReceiver.Rows.Clear()" but it still doesn't work. Can you please try using a GridView instaed of the lables to see if you receive the same results?

Thanks,

V.

Author

Commented:
Hi,

How do Implement session to update the records in the other views? For example when I
move to the screen (View 2) which contains RotationMin control, even and press  the Next button, the value for RotationMin doesn't change, but the value for the current record should be different.

 Please take a look at my latest code, setting dtReceiver.Rows.Clear()
still didn't solve the problem with duplicated values in my CountryUser combobox control.


       Private Sub UpdateGrid()
        Dim XdRotationMin As New Xml.XmlDocument
        Dim RotationMinID As String
        Dim RotationMinID2 As String
        Dim xdManufacturer As New Xml.XmlDocument
       
        Dim ManufacturerID As String
        Dim ManufacturerID2 As String
        Dim astrixState As Integer
        astrixState = 0
        Dim xdlink As New Xml.XmlDocument, xdlinkA As New Xml.XmlDocument, xdlinkB As New Xml.XmlDocument, xdReceiver As New Xml.XmlDocument, Link_ID As String, ReceiverID As String, ReceiverID2 As String, DonorID As String, DonorID2 As String, Name As String
        xdlink.Load(Server.MapPath("LinkSSADB.xml"))
        xdlinkA.Load(Server.MapPath("LinkA.xml"))
        xdlinkB.Load(Server.MapPath("LinkB.xml"))
        xdReceiver.Load(Server.MapPath("CountryUser.xml"))
        xdManufacturer.Load(Server.MapPath("Manufacturer.xml"))
        XdRotationMin.Load(Server.MapPath("RotationMin.xml"))
     
        Dim allSelectionString1 As String = ""
        For itemCounter As Integer = 0 To C1ACountryUser.Items.Count - 1
            If C1ACountryUser.Items(itemCounter).Selected Then
                If allSelectionString1 <> "" Then allSelectionString1 &= " or "
                allSelectionString1 &= "contains(concat(',', CountryUser_ID, ','), '," & C1ACountryUser.Items(itemCounter).Value & ",')"
            End If
        Next

        Dim allSelectionString2 As String = ""
        For itemCounter As Integer = 0 To C1ACountryOrigin.Items.Count - 1
            If C1ACountryOrigin.Items(itemCounter).Selected Then
                If allSelectionString2 <> "" Then allSelectionString2 &= " or "
                allSelectionString2 &= "contains(concat(',', CountryOrigin_ID, ','), '," & C1ACountryOrigin.Items(itemCounter).Value & ",')"
            End If
        Next

     
        Dim allSelectionString4 As String = ""
        If C1Manufacturer.Text <> "" Then
            Dim ManufacturerFound As String = ""
            For Each xnManufacturer As Xml.XmlNode In xdManufacturer.SelectNodes("/Root/ManufacturerTable[contains(Manufacturer, '" & C1Manufacturer.Text & "')]")
                If allSelectionString4 <> "" Then allSelectionString4 &= " or "
                allSelectionString4 &= "contains(concat(',', Manufacturer_ID, ','), '," & xnManufacturer.SelectSingleNode("Manufacturer_ID").InnerText & ",')"
                '' allSelectionString4 &= "contains(concat(Manufacturer_ID), '," & xnManufacturer.SelectSingleNode("Manufacturer_ID").InnerText & ",')"
                If ManufacturerFound <> "" Then ManufacturerFound &= ", "
                ManufacturerFound &= xnManufacturer.SelectSingleNode("Manufacturer").InnerText & " (id " & xnManufacturer.SelectSingleNode("Manufacturer_ID").InnerText & ")"
            Next
            If ManufacturerFound = "" Then
                Label14.Text = "Manufacturer '" & C1Manufacturer.Text & "' not found."
            Else
                Label14.Text = ManufacturerFound
            End If
        End If
        '   MsgBox(allSelectionString4)
        '******************************************************************************************************
       
        Dim dtReceiver As New DataTable
        dtReceiver.Columns.Add(New DataColumn("ID"))
        dtReceiver.Columns.Add(New DataColumn("Name"))

        Dim dtDonor As New DataTable
        dtDonor.Columns.Add(New DataColumn("ID"))
        dtDonor.Columns.Add(New DataColumn("Name"))

        Dim dtManufacturer As New DataTable
        dtManufacturer.Columns.Add(New DataColumn("ID"))
        dtManufacturer.Columns.Add(New DataColumn("Name"))

        Dim dtRotationMin As New DataTable
        dtRotationMin.Columns.Add(New DataColumn("ID"))
        dtRotationMin.Columns.Add(New DataColumn("Name"))

        Dim iCount As Integer = 0
       

        '***************************************************************************
        '   Dim allSelectionStringOverall As String = "(" & allSelectionString1 & ") and (" & allSelectionString2 & ")"
        Dim allSelectionStringOverall As String = ""
        ' all the strings we found in earlier searches are now put in an array for easy handling
        ' For Each selString As String In {allSelectionString1, allSelectionString2, allSelectionString3, allSelectionString4} ' add more as needed

        For Each selString As String In {allSelectionString1, allSelectionString2} ' add more as needed
            ' only process strings that are not empty other wise we get an error on "() and ()"
            If selString <> "" Then
                ' just like in the previous block of code, do not use the operator the first time
                If allSelectionStringOverall <> "" Then allSelectionStringOverall &= " and "
                ' if we want to reverse all selections then this is the position in the string we need to insert "not" so the
                ' next part will return true when it is actually false (so it does NOT contain the selected values)
                If astrixState = 1 Then allSelectionStringOverall &= "not "
                ' here the actual query is inserted within parantheses because it can contain multiple calls to 'contains()' separated by 'or' operators
                allSelectionStringOverall &= "(" & selString & ")"
            End If
        Next
        If allSelectionStringOverall <> "" Then allSelectionStringOverall = "[" & allSelectionStringOverall & "]"
        '*************************************************
        Me.Label15.Text = allSelectionStringOverall
        Previous.Enabled = False
        ButtonNext.Enabled = False

        ' Dim selectedNodes As Xml.XmlNodeList = xdlink.SelectNodes("/Root/LinkA[" & allSelectionStringOverall & "]")
        Dim selectedNodes As Xml.XmlNodeList = xdlink.SelectNodes("/Root/LinkA" & allSelectionStringOverall)

        ' Dim selectedNodes As Xml.XmlNodeList = xdlink.SelectNodes("/Root/LinkA[" & vbatest & "]")
        For Each xnLink As Xml.XmlNode In selectedNodes
            Link_ID = xnLink.SelectSingleNode("LinkAID").InnerText
            ReceiverID = xnLink.SelectSingleNode("CountryUser_ID").InnerText
            DonorID = xnLink.SelectSingleNode("CountryOrigin_ID").InnerText
            iCount += 1
            If iCount < ViewState("CurrentRecord") Then
                Previous.Enabled = True
            ElseIf iCount > ViewState("CurrentRecord") Then
                ButtonNext.Enabled = True
            Else
                Label14.Text = " ( " & iCount & "/ " & selectedNodes.Count & ") "
                For Each xnReceiver As Xml.XmlNode In xdReceiver.SelectNodes("/Root/CountryUserTable[contains('," & ReceiverID & ",', concat(',', CountryUser_ID, ','))]")
                    ReceiverID2 = xnReceiver.SelectSingleNode("CountryUser_ID").InnerText
                    Name = xnReceiver.SelectSingleNode("CountryUser").InnerText
                    dtReceiver.Rows.Add({ReceiverID2, Name})
                Next
                For Each xnDonor As Xml.XmlNode In xdReceiver.SelectNodes("/Root/CountryUserTable[contains('," & DonorID & ",', concat(',', CountryUser_ID, ','))]")
                    DonorID2 = xnDonor.SelectSingleNode("CountryUser_ID").InnerText
                    Name = xnDonor.SelectSingleNode("CountryUser").InnerText
                    dtDonor.Rows.Add({DonorID2, Name})
                Next

             
        For Each xnLinkA As Xml.XmlNode In xdlinkA.SelectNodes("/Root/LinkA[LinkAID='" & Link_ID & "']")
            ManufacturerID = xnLinkA.SelectSingleNode("Manufacturer_ID").InnerText
            For Each xnManufacturer As Xml.XmlNode In xdManufacturer.SelectNodes("/Root/ManufacturerTable[Manufacturer_ID='" & ManufacturerID & "']")
                ManufacturerID2 = xnManufacturer.SelectSingleNode("Manufacturer_ID").InnerText
                Name = xnManufacturer.SelectSingleNode("Manufacturer").InnerText
                dtManufacturer.Rows.Add({ManufacturerID2, Name})
            Next
        Next

       
        For Each xnLinkB As Xml.XmlNode In xdlinkB.SelectNodes("/Root/LinkA[LinkAID='" & Link_ID & "']")
            RotationMinID = xnLinkB.SelectSingleNode("RotationMin_ID").InnerText
            For Each xnRotationMin As Xml.XmlNode In XdRotationMin.SelectNodes("/Root/RotationMinTable[RotationMin_ID='" & RotationMinID & "']")
                RotationMinID2 = xnRotationMin.SelectSingleNode("RotationMin_ID").InnerText
                Name = xnRotationMin.SelectSingleNode("RotationMin").InnerText
                dtRotationMin.Rows.Add({RotationMinID2, Name})
            Next
        Next

        MsgBox(Link_ID)
        'Screen1
        C1CountryUserA.DataSource = dtDonor
        C1CountryUserA.DataMember = "Name"
        C1CountryUserA.DataTextField = "Name"
        C1CountryUserA.DataValueField = "ID"
        C1CountryUserA.DataBind()

        C1CountryOrigin.DataSource = dtReceiver
        C1CountryOrigin.DataMember = "Name"
        C1CountryOrigin.DataTextField = "Name"
        C1CountryOrigin.DataValueField = "ID"
        C1CountryOrigin.DataBind()
        C1Manufacturer.Text = dtManufacturer.Rows(0).Item("Name")

        'Screen 2
        C1RotationMin.Text = dtRotationMin.Rows(0).Item("Name")


        dtReceiver.Rows.Clear()
        dtDonor.Rows.Clear()
        dtManufacturer.Rows.Clear()
        dtRotationMin.Rows.Clear()

Author

Commented:
Hi,

I was able to use session before by putting the ID value in a table, it  worked with      
 
For Each xnLink As Xml.XmlNode In xdlink.SelectNodes("/Root/LinkA[CountryUser_ID='"

But for some reason, I am now getting an error on line:
LinkID2 = xnLink.SelectSingleNode("LinkAID").InnerText

Error message: Object not set to an instance of an object

Any ideas what is causing this error? Do I need to use session or can I keep track of current records while in the other Views using ViewState?
 
  '  For Each xnLink As Xml.XmlNode In xdlink.SelectNodes("/Root/LinkA[CountryUser_ID='" & C1CountryUser.SelectedItem.Value & "']")
        For Each xnLink As Xml.XmlNode In selectedNodes
            Link_ID = xnLink.SelectSingleNode("LinkAID").InnerText
            ReceiverID = xnLink.SelectSingleNode("CountryUser_ID").InnerText
            DonorID = xnLink.SelectSingleNode("CountryOrigin_ID").InnerText
            iCount += 1
            If iCount < ViewState("CurrentRecord") Then
                Previous.Enabled = True
            ElseIf iCount > ViewState("CurrentRecord") Then
                ButtonNext.Enabled = True
            Else
                Label14.Text = " ( " & iCount & "/ " & selectedNodes.Count & ") "
                For Each xnReceiver As Xml.XmlNode In xdReceiver.SelectNodes("/Root/CountryUserTable[contains('," & ReceiverID & ",', concat(',', CountryUser_ID, ','))]")
                    ReceiverID2 = xnReceiver.SelectSingleNode("CountryUser_ID").InnerText
                    Name = xnReceiver.SelectSingleNode("CountryUser").InnerText
                    dtReceiver.Rows.Add({ReceiverID2, Name})
                Next
                For Each xnDonor As Xml.XmlNode In xdReceiver.SelectNodes("/Root/CountryUserTable[contains('," & DonorID & ",', concat(',', CountryUser_ID, ','))]")
                    DonorID2 = xnDonor.SelectSingleNode("CountryUser_ID").InnerText
                    Name = xnDonor.SelectSingleNode("CountryUser").InnerText
                    dtDonor.Rows.Add({DonorID2, Name})
                Next

         LinkID2 = xnLink.SelectSingleNode("LinkAID").InnerText  ******Error
        dtTable.Rows.Add({LinkID2})

*******************************
NextButton Code:

 'ViewState("CurrentRecord") += 1
        dtTable = Session("dtTable")
        Session("currentIndex") = CurrentIndex
        If CurrentIndex < dtTable.Rows.Count - 1 Then
            CurrentIndex += 1
        End If
        UpdateGrid()
Robert SchuttSoftware Engineer

Commented:
I've been trying with ViewStateMode="Enabled" on the C1ComboBox'es but no luck, I lose the data. Maybe it's a problem with the C1 components.

So also, when I go to View2 and back to View1 I lose the data in the country comboboxes. This is apparently not stored in the ViewState. So change the Page_Load for that:

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not IsPostBack Then ' first time
            ViewState("CurrentRecord") = 1
            UpdateGrid()

        End If
        RadioButton2.Checked = False
        Dim CountryUser As New DataSet
        CountryUser.ReadXml(Server.MapPath("~/App_Data/CountryUser.xml"))
        C1ACountryUser.DataSource = CountryUser.Tables(0)
        C1ACountryUser.DataMember = "CountryUser"
        C1ACountryUser.DataTextField = "CountryUser"
        C1ACountryUser.DataValueField = "CountryUser_ID"
        C1ACountryUser.DataBind()

        Dim CountryOrigin As New DataSet
        CountryOrigin.ReadXml(Server.MapPath("~/App_Data/CountryOrigin.xml"))
        C1ACountryOrigin.DataSource = CountryOrigin.Tables(0)
        C1ACountryOrigin.DataMember = "CountryOrigin"
        C1ACountryOrigin.DataTextField = "CountryOrigin"
        C1ACountryOrigin.DataValueField = "CountryOrigin_ID"
        C1ACountryOrigin.DataBind()

        Dim Manufacturer As New DataSet
        Manufacturer.ReadXml(Server.MapPath("~/App_Data/Manufacturer.xml"))
        C1AManufacturer.DataSource = Manufacturer.Tables(0)
        C1AManufacturer.DataMember = "Manufacturer"
        C1AManufacturer.DataTextField = "Manufacturer"
        C1AManufacturer.DataValueField = "Manufacturer_ID"
        C1AManufacturer.DataBind()
    End Sub

Open in new window


Now these files are bound to the control each time the page is constructed.

I'm working on the next step now. The grids need ViewStateMode="Enabled" now because a new page is contructed when you go to a new View. Another option is to build the content of the combo's or grids every time again. But in that case the order of things become important, you can't just call UpdateGrid in Page_Load, because for example you need to execute a button click first which increments the record counter.

This basic understanding should be much more important to you in the end than me fixing this page.
Robert SchuttSoftware Engineer

Commented:
For example see this explanation: http://msdn.microsoft.com/en-us/library/ms178472.aspx 

Do you see how misconstructing a page can lead to empty controls or doubled up lists?
Robert SchuttSoftware Engineer

Commented:
So actually from that page I got the solution for the problem in my previous post, delete all calls to UpdateGrid and do it like this:

    Protected Sub Page_LoadComplete(sender As Object, e As System.EventArgs) Handles Me.LoadComplete
        UpdateGrid()
    End Sub

Open in new window

Robert SchuttSoftware Engineer

Commented:
I couldn't get the lower ComboBox to work (I thought) but it IS working: if you put the cursor in it and press cursor down it showed the list. The arrow is not shown but that is because of the attribute: ShowTrigger="False".

Author

Commented:
\Hi,

Just read your messages, will try your suggestions and get back to you.

Thanks for all your efforts.

V.

Author

Commented:
Hi,

Still having isues with the bottom combobox and not getting current record when navigating from View 2, will run more test tomorrow.

Thanks,

V.
Robert SchuttSoftware Engineer

Commented:
Have a good look at the different attributes on those two ComboBoxes, are those deliberate or have you been trying out various possibilities and forgot to clean up?

Below is what you posted earlier, I took out the ShowTrigger="False" on the second one and got it working. But also why is there a Text="Select" on the first one if you're using it to display the found records? What should the OpenDropDownOnLoad do? I mean it sounds obvious but doesn't work for me.

                        <cc1:C1ComboBox ID="C1CountryOrigin" runat="server" AutoPostBack="True" 
                            DropDownPositioningMode="BottomCenter" 
                            ForceSelectionText="True" Height="32px" IsEditable="False" 
                            style="text-align: left" 
                            Width="60px" Text="Select" OpenDropDownOnLoad="True">
                        </cc1:C1ComboBox>

                     <cc1:C1ComboBox ID="C1CountryUserA" runat="server" Width="60px" 
                         BackColor="#CC6699" 
                         DropDownPositioningMode="RightTop" 
                         IsEditable="False" ShowTrigger="False" AppendDataBoundItems="True" 
                         AutoComplete="False" DropDownResizable="True" MaxLength="35" 
                         OpenDropDownOnLoad="True">
                              </cc1:C1ComboBox>

Open in new window

Author

Commented:
Hi,

Select is in the CountryOrigin Combobox to allow them to select a country during the Update part of the application, forgot to remove it, but it should not have an impact, the OpenDropDownOnLoad shows all the data loaded in a dropdown list and it is working on my side. I will clean up my code and end you the latest, hopefully it will help with solving the remaining two issues.

Thanks,

V.

Author

Commented:
Hi,

I see what you were talking about regarding the bottom combobox, it is now working for me also, the only problem now is when moving to different Views, I am still unable to keep track of the current record. For example When I am in View2 which contains RotationMin, when I click on Next, its value remains the same. I tried using session, but it still doesn't work.


Protected Sub Button173_Click(sender As Object, e As EventArgs) Handles Button173.Click
        ViewState("CurrentRecord") = 1

        UpdateGrid()
        MultiView1.ActiveViewIndex = 1
    End Sub

   Protected Sub NextA_Click(sender As Object, e As EventArgs) Handles NextA.Click
        ViewState("CurrentRecord") += 1
        '  dtTable = Session("dtTable")
        ' dtDonor = Session("dtDonor")
        'dtReceiver = Session("dtReceiver")
        'dtItemA = Session("dtItemA")
        'dtManufacturer = Session("dtManufacturer")
        'CurrentIndex = Session("CurrentIndex")
        'LinkID2 = Session("LinkID2")
        'Session("currentIndex") = CurrentIndex
        ' If CurrentIndex < dtTable.Rows.Count - 1 Then
        'CurrentIndex += 1
        'End If
        UpdateGrid()

    End Sub



Private Sub UpdateGrid()
        Dim xdItemA As New Xml.XmlDocument
        Dim XdRotationMin As New Xml.XmlDocument
        Dim RotationMinID As String
        Dim RotationMinID2 As String
        Dim xdManufacturer As New Xml.XmlDocument
        Dim ItemAID As String
        Dim ItemAID2 As String
        Dim ManufacturerID As String
        Dim ManufacturerID2 As String
        Dim astrixState As Integer
        astrixState = 0
        Dim xdDonor As New Xml.XmlDocument
        Dim xdlink As New Xml.XmlDocument, xdlinkA As New Xml.XmlDocument, xdlinkB As New Xml.XmlDocument, xdReceiver As New Xml.XmlDocument, Link_ID As String, ReceiverID As String, ReceiverID2 As String, DonorID As String, DonorID2 As String, Name As String
        xdlink.Load(Server.MapPath("LinkSSADB.xml"))
        xdlinkA.Load(Server.MapPath("LinkA.xml"))
        xdlinkB.Load(Server.MapPath("LinkB.xml"))
        xdReceiver.Load(Server.MapPath("CountryUser.xml"))
        xdDonor.Load(Server.MapPath("CountryUser.xml"))
        xdItemA.Load(Server.MapPath("ItemA.xml"))   '1
        xdManufacturer.Load(Server.MapPath("Manufacturer.xml"))
        XdRotationMin.Load(Server.MapPath("RotationMin.xml"))
     
        Dim allSelectionString1 As String = ""
        For itemCounter As Integer = 0 To C1ACountryUser.Items.Count - 1
            If C1ACountryUser.Items(itemCounter).Selected Then
                If allSelectionString1 <> "" Then allSelectionString1 &= " or "
                allSelectionString1 &= "contains(concat(',', CountryUser_ID, ','), '," & C1ACountryUser.Items(itemCounter).Value & ",')"
            End If
        Next
        MsgBox(allSelectionString1)
        Dim allSelectionString2 As String = ""
        For itemCounter As Integer = 0 To C1ACountryOrigin.Items.Count - 1
            If C1ACountryOrigin.Items(itemCounter).Selected Then
                If allSelectionString2 <> "" Then allSelectionString2 &= " or "
                allSelectionString2 &= "contains(concat(',', CountryOrigin_ID, ','), '," & C1ACountryOrigin.Items(itemCounter).Value & ",')"
            End If
        Next
        MsgBox(allSelectionString2)
        Dim allSelectionString3 As String = "" '2
        For itemCounter As Integer = 0 To C1AItemA.Items.Count - 1
            If C1AItemA.Items(itemCounter).Selected Then
                If allSelectionString3 <> "" Then allSelectionString3 &= " or "
                allSelectionString3 &= "contains(concat(',', ItemA_ID, ','), '," & C1AItemA.Items(itemCounter).Value & ",')"
            End If
        Next
        '  MsgBox(allSelectionString3)

     
        Dim allSelectionString4 As String = ""
        If C1Manufacturer.Text <> "" Then
            Dim ManufacturerFound As String = ""
            For Each xnManufacturer As Xml.XmlNode In xdManufacturer.SelectNodes("/Root/ManufacturerTable[contains(Manufacturer, '" & C1Manufacturer.Text & "')]")
                If allSelectionString4 <> "" Then allSelectionString4 &= " or "
                allSelectionString4 &= "contains(concat(',', Manufacturer_ID, ','), '," & xnManufacturer.SelectSingleNode("Manufacturer_ID").InnerText & ",')"
                '' allSelectionString4 &= "contains(concat(Manufacturer_ID), '," & xnManufacturer.SelectSingleNode("Manufacturer_ID").InnerText & ",')"
                If ManufacturerFound <> "" Then ManufacturerFound &= ", "
                ManufacturerFound &= xnManufacturer.SelectSingleNode("Manufacturer").InnerText & " (id " & xnManufacturer.SelectSingleNode("Manufacturer_ID").InnerText & ")"
            Next
            If ManufacturerFound = "" Then
                Label14.Text = "Manufacturer '" & C1Manufacturer.Text & "' not found."
            Else
                Label14.Text = ManufacturerFound
            End If
        End If
        '   MsgBox(allSelectionString4)
        '******************************************************************************************************
     

        Dim dtReceiver As New DataTable
        dtReceiver.Columns.Add(New DataColumn("ID"))
        dtReceiver.Columns.Add(New DataColumn("Name"))

        Dim dtDonor As New DataTable
        dtDonor.Columns.Add(New DataColumn("ID"))
        dtDonor.Columns.Add(New DataColumn("Name"))

        Dim dtItemA As New DataTable '3
        dtItemA.Columns.Add(New DataColumn("ID"))
        dtItemA.Columns.Add(New DataColumn("Name"))

        Dim dtManufacturer As New DataTable
        dtManufacturer.Columns.Add(New DataColumn("ID"))
        dtManufacturer.Columns.Add(New DataColumn("Name"))

        Dim dtRotationMin As New DataTable
        dtRotationMin.Columns.Add(New DataColumn("ID"))
        dtRotationMin.Columns.Add(New DataColumn("Name"))

        Session("CurrentIndex") = 0
        dtTable = New DataTable
        dtTable.Columns.Add("LinkID2", GetType(Integer))

        'Screen 1
        Session("dtTable") = dtTable
        Session("dtItemA") = dtDonor
        Session("dtDonor") = dtDonor
        Session("dtReceiver") = dtReceiver
        Session("dtManufacturer") = dtManufacturer

        'Screen 2

        Session("dtRotationMin") = dtRotationMin
        Session("LinkID2") = LinkID2
        Session("dtLinkID") = dtLinkID
        Link_ID = ""
        Dim iCount As Integer = 0
       

        '***************************************************************************
        '   Dim allSelectionStringOverall As String = "(" & allSelectionString1 & ") and (" & allSelectionString2 & ")"
        Dim allSelectionStringOverall As String = ""
        ' all the strings we found in earlier searches are now put in an array for easy handling
        ' For Each selString As String In {allSelectionString1, allSelectionString2, allSelectionString3, allSelectionString4} ' add more as needed

        For Each selString As String In {allSelectionString1, allSelectionString2, allSelectionString3} ' add more as needed
            ' only process strings that are not empty other wise we get an error on "() and ()"
            If selString <> "" Then
                ' just like in the previous block of code, do not use the operator the first time
                If allSelectionStringOverall <> "" Then allSelectionStringOverall &= " and "
                ' if we want to reverse all selections then this is the position in the string we need to insert "not" so the
                ' next part will return true when it is actually false (so it does NOT contain the selected values)
                If astrixState = 1 Then allSelectionStringOverall &= "not "
                ' here the actual query is inserted within parantheses because it can contain multiple calls to 'contains()' separated by 'or' operators
                allSelectionStringOverall &= "(" & selString & ")"
            End If
        Next
        If allSelectionStringOverall <> "" Then allSelectionStringOverall = "[" & allSelectionStringOverall & "]"
        '*************************************************
        Me.Label15.Text = allSelectionStringOverall
        Previous.Enabled = False
        ButtonNext.Enabled = False

        ' Dim selectedNodes As Xml.XmlNodeList = xdlink.SelectNodes("/Root/LinkA[" & allSelectionStringOverall & "]")
        Dim selectedNodes As Xml.XmlNodeList = xdlink.SelectNodes("/Root/LinkA" & allSelectionStringOverall)

        ' Dim selectedNodes As Xml.XmlNodeList = xdlink.SelectNodes("/Root/LinkA[" & vbatest & "]")
        ' For Each xnLink As Xml.XmlNode In selectedNodes
        '  For Each xnLink As Xml.XmlNode In xdlink.SelectNodes("/Root/LinkA[ItemA_ID='" & C1ItemA.SelectedItem.Value & "']")
        For Each xnLink As Xml.XmlNode In selectedNodes
            Link_ID = xnLink.SelectSingleNode("LinkAID").InnerText
            ReceiverID = xnLink.SelectSingleNode("CountryUser_ID").InnerText
            DonorID = xnLink.SelectSingleNode("CountryOrigin_ID").InnerText
            ItemAID = xnLink.SelectSingleNode("ItemA_ID").InnerText '4
            iCount += 1
            If iCount < ViewState("CurrentRecord") Then
                Previous.Enabled = True
            ElseIf iCount > ViewState("CurrentRecord") Then
                ButtonNext.Enabled = True
            Else
                Label14.Text = " ( " & iCount & "/ " & selectedNodes.Count & ") "
                For Each xnReceiver As Xml.XmlNode In xdReceiver.SelectNodes("/Root/CountryUserTable[contains('," & ReceiverID & ",', concat(',', CountryUser_ID, ','))]")
                    ReceiverID2 = xnReceiver.SelectSingleNode("CountryUser_ID").InnerText
                    Name = xnReceiver.SelectSingleNode("CountryUser").InnerText
                    dtReceiver.Rows.Add({ReceiverID2, Name})
                Next
                For Each xnDonor As Xml.XmlNode In xdDonor.SelectNodes("/Root/CountryUserTable[contains('," & DonorID & ",', concat(',', CountryUser_ID, ','))]")
                    DonorID2 = xnDonor.SelectSingleNode("CountryUser_ID").InnerText
                    Name = xnDonor.SelectSingleNode("CountryUser").InnerText
                    dtDonor.Rows.Add({DonorID2, Name})
                Next

                For Each xnItemA As Xml.XmlNode In xdItemA.SelectNodes("/Root/ItemATable[contains('," & ItemAID & ",', concat(',', ItemA_ID, ','))]") '5
                    ItemAID2 = xnItemA.SelectSingleNode("ItemA_ID").InnerText
                    Name = xnItemA.SelectSingleNode("ItemA").InnerText
                    dtItemA.Rows.Add({ItemAID2, Name})
                Next
            End If

            LinkID2 = xnLink.SelectSingleNode("LinkAID").InnerText
            dtTable.Rows.Add({LinkID2})

            For Each xnLinkA As Xml.XmlNode In xdlinkA.SelectNodes("/Root/LinkA[LinkAID='" & LinkID2 & "']")
                ManufacturerID = xnLinkA.SelectSingleNode("Manufacturer_ID").InnerText
                For Each xnManufacturer As Xml.XmlNode In xdManufacturer.SelectNodes("/Root/ManufacturerTable[Manufacturer_ID='" & ManufacturerID & "']")
                    ManufacturerID2 = xnManufacturer.SelectSingleNode("Manufacturer_ID").InnerText
                    Name = xnManufacturer.SelectSingleNode("Manufacturer").InnerText
                    dtManufacturer.Rows.Add({ManufacturerID2, Name})
                Next
            Next

            For Each xnLinkB As Xml.XmlNode In xdlinkB.SelectNodes("/Root/LinkA[LinkAID='" & LinkID2 & "']")
                RotationMinID = xnLinkB.SelectSingleNode("RotationMin_ID").InnerText
                For Each xnRotationMin As Xml.XmlNode In XdRotationMin.SelectNodes("/Root/RotationMinTable[RotationMin_ID='" & RotationMinID & "']")
                    RotationMinID2 = xnRotationMin.SelectSingleNode("RotationMin_ID").InnerText
                    Name = xnRotationMin.SelectSingleNode("RotationMin").InnerText
                    dtRotationMin.Rows.Add({RotationMinID2, Name})
                Next
            Next
        Next

        'Screen1
        C1ItemA.DataSource = dtItemA
        C1ItemA.DataMember = "Name"
        C1ItemA.DataTextField = "Name"
        C1ItemA.DataValueField = "ID"
        C1ItemA.DataBind()

        C1CountryUserA.DataSource = dtReceiver
        C1CountryUserA.DataMember = "Name"
        C1CountryUserA.DataTextField = "Name"
        C1CountryUserA.DataValueField = "ID"
        C1CountryUserA.DataBind()

        C1CountryOrigin.DataSource = dtDonor
        C1CountryOrigin.DataMember = "Name"
        C1CountryOrigin.DataTextField = "Name"
        C1CountryOrigin.DataValueField = "ID"
        C1CountryOrigin.DataBind()
        C1Manufacturer.Text = dtManufacturer.Rows(0).Item("Name")

        'Screen 2
        C1RotationMin.Text = dtRotationMin.Rows(0).Item("Name")

        dtReceiver.Rows.Clear()
        dtItemA.Rows.Clear()
        dtDonor.Rows.Clear()
        dtManufacturer.Rows.Clear()
        dtRotationMin.Rows.Clear()
    End Sub
Software Engineer
Commented:
Did you implement the Page_LoadComplete() I suggested earlier?

If no, why not?

If yes, then you forgot to remove the call to UpdateGrid() in Button173_Click, if you use this construction this should only be called from Page_LoadComplete().

I can't test your latest code because you've made changes to the html/aspx and I can't keep guessing what I need to do to make it work. It's very counter-productive to keep changing things, going from problem to problem. Please let's try to get the basis right first.

Have you done the change in Page_Load I posted earlier? Note that now some of the code is inside the "If", some outside the "If" so it's executed every time.

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not IsPostBack Then ' first time
            ViewState("CurrentRecord") = 1
            UpdateGrid()

        End If
        RadioButton2.Checked = False
        Dim CountryUser As New DataSet
        CountryUser.ReadXml(Server.MapPath("~/App_Data/CountryUser.xml"))
        C1ACountryUser.DataSource = CountryUser.Tables(0)
        C1ACountryUser.DataMember = "CountryUser"
        C1ACountryUser.DataTextField = "CountryUser"
        C1ACountryUser.DataValueField = "CountryUser_ID"
        C1ACountryUser.DataBind()

        Dim CountryOrigin As New DataSet
        CountryOrigin.ReadXml(Server.MapPath("~/App_Data/CountryOrigin.xml"))
        C1ACountryOrigin.DataSource = CountryOrigin.Tables(0)
        C1ACountryOrigin.DataMember = "CountryOrigin"
        C1ACountryOrigin.DataTextField = "CountryOrigin"
        C1ACountryOrigin.DataValueField = "CountryOrigin_ID"
        C1ACountryOrigin.DataBind()

        Dim Manufacturer As New DataSet
        Manufacturer.ReadXml(Server.MapPath("~/App_Data/Manufacturer.xml"))
        C1AManufacturer.DataSource = Manufacturer.Tables(0)
        C1AManufacturer.DataMember = "Manufacturer"
        C1AManufacturer.DataTextField = "Manufacturer"
        C1AManufacturer.DataValueField = "Manufacturer_ID"
        C1AManufacturer.DataBind()
    End Sub

Open in new window

Author

Commented:
Hi,

Just read your message. will get back to you within the hour.

Thanks,

V.

Author

Commented:
Hi,

I'm sorry for confusing matters. I know you are doing your best to help me and I really appreciate it.

I followed your instructions but the data in View2 still doesn't update when I click on the next button. My project includes lots of more code which may be executing inadvertently.

Can you please send me your project or aspx and aspxvb code and I will create a small project to make sure we are using the same files?
 
Thanks,

V.
Robert SchuttSoftware Engineer

Commented:
Sure.

Note the slightly different C1 installation I downloaded: "C1.Web.Wijmo.Controls", you can replace your version back in there.
Default.aspx
Default.aspx.vb

Author

Commented:
Thanks! Will get back to you as soon as I have it running.

Author

Commented:
Hi,

Can't seem to be able to include my componentone controls in your project, I think yiou had the same issue (enclosed error message) will need to create a new and match the names of of your control. Which control did you have in View2?
Were you able to see the changes in the control in View2 when you clicked on the Next button?

Need to head home now, will work on it as soon as I get home.

V.
errorview.pptx
Robert SchuttSoftware Engineer

Commented:
See screendump.

Yes I did have that error but it was because I have a slightly different version of C1, don't know why exactly maybe just downloaded another version but it works when you set these the same as for your existing project:
- reference in project to C1 assembly
- <@register assembly...> tag (in .aspx)
- imports C1... (in .aspx.vb)

The controls themselves are the same as far as I can tell, you can see that in the files I posted before.
working.png

Author

Commented:
I am looking at your version, we were not on the same page, my fault for not being clear.

When I said View 2, I meant View 3, which you don't have. I did not consider the view with where we filter the data as a View to see the results. I am creating a new project now with an additional view (View 3) containing the RotationMin control, will send it to you as soon as I'm done. As mentioned the value of RotationMin does not change when I press on the Next button. For example, if my search returns 2 records with RotationMin vaues 1234 for the first record and 5678 for the second record. View3 still shows 1234 even when I move to the second record. When I press Nect I need to keep track of the current record for all the Views in order to see the correct values.

Author

Commented:
Hi,

I created a new project (Link below) but when trying to run it I keep getting error message for the ComponenntOne controls, please try to replace them with the controls you were using.

'C1RotationMin' is not declared. It may be inaccessible due to its protection level.

http://speedy.sh/w4a9f/WebApplication6.zip

Thanks,

V.

Author

Commented:
Hi,

The message box is given me the right count but the Textcontrol doesn't work, I tried using the textcontrol that comes with VS2010 but it's still not working. Any ideas what is causing this problem?

MsgBox(dtRotationMin.Rows.Count)
 'C1RotationMin.Text = dtRotationMin.Rows(0).Item("Name")

Author

Commented:
I think the problem is I need to use
'C1RotationMin.Text = dtRotationMin.Rows(CurrentIndex).Item("Name")
because
'C1RotationMin.Text = dtRotationMin.Rows(0).Item("Name")
will always give me the first row.

Will keep testing....

Author

Commented:
The code below is an example of what I used in a search feature of my application, can it be modified to include  ViewState("CurrentRecord") and still use UpdateGrid()
 to avoid writing more code in the click event of the Next and Previous buttons?

I'm working with about 80 datafield and 9 screens, once I resolve this issue, is there a way to view one screen at a time? I'm afraid speed migh be an issue if the users have to wait for all 9 screens to be populated before data is displayed on the first screen. For example can a method be called for each screen, display data than call another method?


Protected Sub ButtonNext_Click(ByVal sender As Object, ByVal e As EventArgs) Handles ButtonNext.Click

'Screen 1
        dtTable = Session("dtTable")
        dtDonor = Session("dtDonor")
        dtReceiver = Session("dtReceiver")
        CurrentIndex = Session("CurrentIndex”)
        dtManufacturer = Session("dtManufacturer")
        LinkID2 = Session("LinkID2")

'Screen 2

        dtRotationMin = Session("dtRotationMin")


        If CurrentIndex < dtTable.Rows.Count - 1 Then
            CurrentIndex += 1
            Session("CurrentIndex") = CurrentIndex



         C1CountryOrigin.Text = dtDonor.Rows(CurrentIndex).Item("CountryOrigin")
         C1CountryUserA.Text = dtReceiver.Rows(CurrentIndex).Item("CountryUser")
         C1Manufacturer.Text = dtManufacturer.Rows(CurrentIndex).Item("Manufacturer")

        'Screen 2
            C1RotationMin.Text = dtRotationMin.Rows(CurrentIndex).Item("RotationMin")

           End If
Robert SchuttSoftware Engineer

Commented:
Ok, I need some time to get up to speed. I have downloaded the zip and will look at that momentarily.

But to answer your last question first: yes, you can decide which controls to fill from UpgradeGrid using MultiView1.ActiveIndex, so you only spend time on the controls that will be displayed in the current View.

Author

Commented:
Hi,

I made some progress, was able to see the different RotationMin values in View3 but when I ran a search which gave me 8 records, when I press the Next button to go to the the last record (8). I received the folowing error:

There is no row at position 8.

on line:

   C1RotationMin.Text = dtRotationMin.Rows(ViewState("CurrentRecord")).Item("Name")


The RotationMin ID and its value exist in RotationMin.xml and its ID does wxist in LinkB.xml, any ideas what is causing this error? The error occurs after icount = 8.

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not IsPostBack Then ' first time
            ViewState("CurrentRecord") = 1
        End If
    End Sub

 Protected Sub Button173_Click(sender As Object, e As EventArgs) Handles Button173.Click
        MultiView1.ActiveViewIndex = 1
    End Sub


 Protected Sub NextA_Click(sender As Object, e As EventArgs) Handles NextA.Click
        ViewState("CurrentRecord") += 1
    End Sub


Private Sub Page_LoadComplete(sender As Object, e As System.EventArgs) Handles Me.LoadComplete
        UpdateGrid()
    End Sub

  Protected Sub Button169_Click(sender As Object, e As EventArgs) Handles Previous.Click
        ViewState("CurrentRecord") -= 1
    End Sub



  Private Sub UpdateGrid()
        Dim XdRotationMin As New Xml.XmlDocument
        Dim RotationMinID As String
        Dim RotationMinID2 As String
        Dim xdManufacturer As New Xml.XmlDocument
        Dim ManufacturerID As String
        Dim ManufacturerID2 As String
        Dim astrixState As Integer
        astrixState = 0
        Dim xdDonor As New Xml.XmlDocument
        Dim xdlink As New Xml.XmlDocument, xdlinkA As New Xml.XmlDocument, xdlinkB As New Xml.XmlDocument, xdReceiver As New Xml.XmlDocument, Link_ID As String, ReceiverID As String, ReceiverID2 As String, DonorID As String, DonorID2 As String, Name As String
        xdlink.Load(Server.MapPath("LinkSSADB.xml"))
        xdlinkA.Load(Server.MapPath("LinkA.xml"))
        xdlinkB.Load(Server.MapPath("LinkB.xml"))
        xdReceiver.Load(Server.MapPath("CountryUser.xml"))
        xdDonor.Load(Server.MapPath("CountryUser.xml"))
        xdManufacturer.Load(Server.MapPath("Manufacturer.xml"))
        XdRotationMin.Load(Server.MapPath("RotationMin.xml"))
     
        Dim allSelectionString1 As String = ""
        For itemCounter As Integer = 0 To C1ACountryUser.Items.Count - 1
            If C1ACountryUser.Items(itemCounter).Selected Then
                If allSelectionString1 <> "" Then allSelectionString1 &= " or "
                allSelectionString1 &= "contains(concat(',', CountryUser_ID, ','), '," & C1ACountryUser.Items(itemCounter).Value & ",')"
            End If
        Next
        Dim allSelectionString2 As String = ""
        For itemCounter As Integer = 0 To C1ACountryOrigin.Items.Count - 1
            If C1ACountryOrigin.Items(itemCounter).Selected Then
                If allSelectionString2 <> "" Then allSelectionString2 &= " or "
                allSelectionString2 &= "contains(concat(',', CountryOrigin_ID, ','), '," & C1ACountryOrigin.Items(itemCounter).Value & ",')"
            End If
        Next

        Dim allSelectionString4 As String = ""
        If C1Manufacturer.Text <> "" Then
            Dim ManufacturerFound As String = ""
            For Each xnManufacturer As Xml.XmlNode In xdManufacturer.SelectNodes("/Root/ManufacturerTable[contains(Manufacturer, '" & C1Manufacturer.Text & "')]")
                If allSelectionString4 <> "" Then allSelectionString4 &= " or "
                allSelectionString4 &= "contains(concat(',', Manufacturer_ID, ','), '," & xnManufacturer.SelectSingleNode("Manufacturer_ID").InnerText & ",')"
                '' allSelectionString4 &= "contains(concat(Manufacturer_ID), '," & xnManufacturer.SelectSingleNode("Manufacturer_ID").InnerText & ",')"
                If ManufacturerFound <> "" Then ManufacturerFound &= ", "
                ManufacturerFound &= xnManufacturer.SelectSingleNode("Manufacturer").InnerText & " (id " & xnManufacturer.SelectSingleNode("Manufacturer_ID").InnerText & ")"
            Next
            If ManufacturerFound = "" Then
                Label14.Text = "Manufacturer '" & C1Manufacturer.Text & "' not found."
            Else
                Label14.Text = ManufacturerFound
            End If
        End If
        '******************************************************************************************************
     

        Dim dtReceiver As New DataTable
        dtReceiver.Columns.Add(New DataColumn("ID"))
        dtReceiver.Columns.Add(New DataColumn("Name"))

        Dim dtDonor As New DataTable
        dtDonor.Columns.Add(New DataColumn("ID"))
        dtDonor.Columns.Add(New DataColumn("Name"))

       

        Dim dtManufacturer As New DataTable
        dtManufacturer.Columns.Add(New DataColumn("ID"))
        dtManufacturer.Columns.Add(New DataColumn("Name"))

        Dim dtRotationMin As New DataTable
        dtRotationMin.Columns.Add(New DataColumn("ID"))
        dtRotationMin.Columns.Add(New DataColumn("Name"))

        Session("CurrentIndex") = 0
        dtTable = New DataTable
        dtTable.Columns.Add("LinkID2", GetType(Integer))

        'Screen 1
     
        'Screen 2

        Link_ID = ""
        Dim iCount As Integer = 0
       

        '***************************************************************************
        '   Dim allSelectionStringOverall As String = "(" & allSelectionString1 & ") and (" & allSelectionString2 & ")"
        Dim allSelectionStringOverall As String = ""
        ' all the strings we found in earlier searches are now put in an array for easy handling
        ' For Each selString As String In {allSelectionString1, allSelectionString2, allSelectionString3, allSelectionString4} ' add more as needed

        For Each selString As String In {allSelectionString1, allSelectionString2, allSelectionString3} ' add more as needed
            ' only process strings that are not empty other wise we get an error on "() and ()"
            If selString <> "" Then
                ' just like in the previous block of code, do not use the operator the first time
                If allSelectionStringOverall <> "" Then allSelectionStringOverall &= " and "
                ' if we want to reverse all selections then this is the position in the string we need to insert "not" so the
                ' next part will return true when it is actually false (so it does NOT contain the selected values)
                If astrixState = 1 Then allSelectionStringOverall &= "not "
                ' here the actual query is inserted within parantheses because it can contain multiple calls to 'contains()' separated by 'or' operators
                allSelectionStringOverall &= "(" & selString & ")"
            End If
        Next
        If allSelectionStringOverall <> "" Then allSelectionStringOverall = "[" & allSelectionStringOverall & "]"
        '  MsgBox(allSelectionStringOverall)
        '*************************************************
        Me.Label15.Text = allSelectionStringOverall
        Previous.Enabled = False
        Nexta.Enabled = False

        ' Dim selectedNodes As Xml.XmlNodeList = xdlink.SelectNodes("/Root/LinkA[" & allSelectionStringOverall & "]")
        Dim selectedNodes As Xml.XmlNodeList = xdlink.SelectNodes("/Root/LinkA" & allSelectionStringOverall)

        ' Dim selectedNodes As Xml.XmlNodeList = xdlink.SelectNodes("/Root/LinkA[" & vbatest & "]")
        ' For Each xnLink As Xml.XmlNode In selectedNodes
        For Each xnLink As Xml.XmlNode In selectedNodes
            Link_ID = xnLink.SelectSingleNode("LinkAID").InnerText
            ReceiverID = xnLink.SelectSingleNode("CountryUser_ID").InnerText
            DonorID = xnLink.SelectSingleNode("CountryOrigin_ID").InnerText
                        iCount += 1
            If iCount < ViewState("CurrentRecord") Then
                Previous.Enabled = True
            ElseIf iCount > ViewState("CurrentRecord") Then
                NextA.Enabled = True
            Else
                Label15.Text = " ( " & iCount & "/ " & selectedNodes.Count & ") "
                For Each xnReceiver As Xml.XmlNode In xdReceiver.SelectNodes("/Root/CountryUserTable[contains('," & ReceiverID & ",', concat(',', CountryUser_ID, ','))]")
                    ReceiverID2 = xnReceiver.SelectSingleNode("CountryUser_ID").InnerText
                    Name = xnReceiver.SelectSingleNode("CountryUser").InnerText
                    dtReceiver.Rows.Add({ReceiverID2, Name})
                Next
                For Each xnDonor As Xml.XmlNode In xdDonor.SelectNodes("/Root/CountryUserTable[contains('," & DonorID & ",', concat(',', CountryUser_ID, ','))]")
                    DonorID2 = xnDonor.SelectSingleNode("CountryUser_ID").InnerText
                    Name = xnDonor.SelectSingleNode("CountryUser").InnerText
                    dtDonor.Rows.Add({DonorID2, Name})
                Next

            End If

            LinkID2 = xnLink.SelectSingleNode("LinkAID").InnerText
            dtTable.Rows.Add({LinkID2})

            For Each xnLinkA As Xml.XmlNode In xdlinkA.SelectNodes("/Root/LinkA[LinkAID='" & LinkID2 & "']")
                ManufacturerID = xnLinkA.SelectSingleNode("Manufacturer_ID").InnerText
                For Each xnManufacturer As Xml.XmlNode In xdManufacturer.SelectNodes("/Root/ManufacturerTable[Manufacturer_ID='" & ManufacturerID & "']")
                    ManufacturerID2 = xnManufacturer.SelectSingleNode("Manufacturer_ID").InnerText
                    Name = xnManufacturer.SelectSingleNode("Manufacturer").InnerText
                    dtManufacturer.Rows.Add({ManufacturerID2, Name})
                Next
            Next

            For Each xnLinkB As Xml.XmlNode In xdlinkB.SelectNodes("/Root/LinkA[LinkAID='" & LinkID2 & "']")
                RotationMinID = xnLinkB.SelectSingleNode("RotationMin_ID").InnerText
                For Each xnRotationMin As Xml.XmlNode In XdRotationMin.SelectNodes("/Root/RotationMinTable[RotationMin_ID='" & RotationMinID & "']")
                    RotationMinID2 = xnRotationMin.SelectSingleNode("RotationMin_ID").InnerText
                    Name = xnRotationMin.SelectSingleNode("RotationMin").InnerText
                    dtRotationMin.Rows.Add({RotationMinID2, Name})
                Next
            Next
        Next

        'Screen1

        C1CountryUser.DataSource = dtReceiver
        C1CountryUser.DataMember = "Name"
        C1CountryUser.DataTextField = "Name"
        C1CountryUser.DataValueField = "ID"
        C1CountryUser.DataBind()

        C1CountryOrigin.DataSource = dtDonor
        C1CountryOrigin.DataMember = "Name"
        C1CountryOrigin.DataTextField = "Name"
        C1CountryOrigin.DataValueField = "ID"
        C1CountryOrigin.DataBind()

        C1Manufacturer.Text = dtManufacturer.Rows(CurrentIndex).Item("Name")
        'Screen 2
        C1RotationMin.Text = dtRotationMin.Rows(ViewState("CurrentRecord")).Item("Name")  *****Error on last record found

Author

Commented:
Hi,

Below is the code to display data in each screen at a time (first two screens), is this the approach you would take? or is there a smarter way to do this? As mentioned I need to display the firast screen quickly since the application will process a lot of data, which can cause a big delay in showing the first screen.

Also I noticed every time I press a control with postback set to True, the UpdateGrid method executes, is there a way to execute this metho only when the users presses the Search and Navigation button?

Private Sub UpdateGrid()
        Dim astrixState As Integer
        astrixState = 0
        Dim xdDonor As New Xml.XmlDocument
        Dim xdlink As New Xml.XmlDocument, xdlinkA As New Xml.XmlDocument, xdlinkB As New Xml.XmlDocument, xdReceiver As New Xml.XmlDocument, Link_ID As String, ReceiverID As String, ReceiverID2 As String, DonorID As String, DonorID2 As String, Name As String
        xdlink.Load(Server.MapPath("LinkSSADB.xml"))
        xdlinkA.Load(Server.MapPath("LinkA.xml"))
        xdlinkB.Load(Server.MapPath("LinkB.xml"))
        xdReceiver.Load(Server.MapPath("CountryUser.xml"))
        xdDonor.Load(Server.MapPath("CountryUser.xml"))
        xdManufacturer.Load(Server.MapPath("Manufacturer.xml"))
             
        Dim allSelectionString1 As String = ""
        For itemCounter As Integer = 0 To C1ACountryUser.Items.Count - 1
            If C1ACountryUser.Items(itemCounter).Selected Then
                If allSelectionString1 <> "" Then allSelectionString1 &= " or "
                allSelectionString1 &= "contains(concat(',', CountryUser_ID, ','), '," & C1ACountryUser.Items(itemCounter).Value & ",')"
            End If
        Next
        Dim allSelectionString2 As String = ""
        For itemCounter As Integer = 0 To C1ACountryOrigin.Items.Count - 1
            If C1ACountryOrigin.Items(itemCounter).Selected Then
                If allSelectionString2 <> "" Then allSelectionString2 &= " or "
                allSelectionString2 &= "contains(concat(',', CountryOrigin_ID, ','), '," & C1ACountryOrigin.Items(itemCounter).Value & ",')"
            End If
        Next
        Dim allSelectionString3 As String = "" 
        Dim allSelectionString4 As String = ""
        If C1Manufacturer.Text <> "" Then
            Dim ManufacturerFound As String = ""
            For Each xnManufacturer As Xml.XmlNode In xdManufacturer.SelectNodes("/Root/ManufacturerTable[contains(Manufacturer, '" & C1Manufacturer.Text & "')]")
                If allSelectionString4 <> "" Then allSelectionString4 &= " or "
                allSelectionString4 &= "contains(concat(',', Manufacturer_ID, ','), '," & xnManufacturer.SelectSingleNode("Manufacturer_ID").InnerText & ",')"
                '' allSelectionString4 &= "contains(concat(Manufacturer_ID), '," & xnManufacturer.SelectSingleNode("Manufacturer_ID").InnerText & ",')"
                If ManufacturerFound <> "" Then ManufacturerFound &= ", "
                ManufacturerFound &= xnManufacturer.SelectSingleNode("Manufacturer").InnerText & " (id " & xnManufacturer.SelectSingleNode("Manufacturer_ID").InnerText & ")"
            Next
            If ManufacturerFound = "" Then
                Label14.Text = "Manufacturer '" & C1Manufacturer.Text & "' not found."
            Else
                Label14.Text = ManufacturerFound
            End If
        End If
        '******************************************************************************************************
     

        Dim dtReceiver As New DataTable
        dtReceiver.Columns.Add(New DataColumn("ID"))
        dtReceiver.Columns.Add(New DataColumn("Name"))

        Dim dtDonor As New DataTable
        dtDonor.Columns.Add(New DataColumn("ID"))
        dtDonor.Columns.Add(New DataColumn("Name"))


        Dim dtManufacturer As New DataTable
        dtManufacturer.Columns.Add(New DataColumn("ID"))
        dtManufacturer.Columns.Add(New DataColumn("Name"))


        Dim iCount As Integer = 0
       
        Dim allSelectionStringOverall As String = ""
       
        For Each selString As String In {allSelectionString1, allSelectionString2, allSelectionString3}
        If selString <> "" Then
                                If allSelectionStringOverall <> "" Then allSelectionStringOverall &= " and "
       If astrixState = 1 Then allSelectionStringOverall &= "not "
       allSelectionStringOverall &= "(" & selString & ")"
       End If
        Next
        If allSelectionStringOverall <> "" Then allSelectionStringOverall = "[" & allSelectionStringOverall & "]"
        Previous.Enabled = False
        Nexta.Enabled = False

        Dim selectedNodes As Xml.XmlNodeList = xdlink.SelectNodes("/Root/LinkA" & allSelectionStringOverall)

‘Screen 1
        For Each xnLink As Xml.XmlNode In selectedNodes
            Link_ID = xnLink.SelectSingleNode("LinkAID").InnerText
            ReceiverID = xnLink.SelectSingleNode("CountryUser_ID").InnerText
            DonorID = xnLink.SelectSingleNode("CountryOrigin_ID").InnerText
           
            iCount += 1
            If iCount < ViewState("CurrentRecord") Then
                Previous.Enabled = True
            ElseIf iCount > ViewState("CurrentRecord") Then
                NextA.Enabled = True
            Else
                MsgBox("icount")
                MsgBox(iCount)
                Label15.Text = " ( " & iCount & "/ " & selectedNodes.Count & ") "
                For Each xnReceiver As Xml.XmlNode In xdReceiver.SelectNodes("/Root/CountryUserTable[contains('," & ReceiverID & ",', concat(',', CountryUser_ID, ','))]")
                    ReceiverID2 = xnReceiver.SelectSingleNode("CountryUser_ID").InnerText
                    Name = xnReceiver.SelectSingleNode("CountryUser").InnerText
                    dtReceiver.Rows.Add({ReceiverID2, Name})
                Next
                For Each xnDonor As Xml.XmlNode In xdDonor.SelectNodes("/Root/CountryUserTable[contains('," & DonorID & ",', concat(',', CountryUser_ID, ','))]")
                    DonorID2 = xnDonor.SelectSingleNode("CountryUser_ID").InnerText
                    Name = xnDonor.SelectSingleNode("CountryUser").InnerText
                    dtDonor.Rows.Add({DonorID2, Name})
                Next


            LinkID2 = xnLink.SelectSingleNode("LinkAID").InnerText
           

            For Each xnLinkA As Xml.XmlNode In xdlinkA.SelectNodes("/Root/LinkA[LinkAID='" & LinkID2 & "']")
                ManufacturerID = xnLinkA.SelectSingleNode("Manufacturer_ID").InnerText
                For Each xnManufacturer As Xml.XmlNode In xdManufacturer.SelectNodes("/Root/ManufacturerTable[Manufacturer_ID='" & ManufacturerID & "']")
                    ManufacturerID2 = xnManufacturer.SelectSingleNode("Manufacturer_ID").InnerText
                    Name = xnManufacturer.SelectSingleNode("Manufacturer").InnerText
                    dtManufacturer.Rows.Add({ManufacturerID2, Name})
                Next
            Next

           
        Next

        'Screen1

        C1CountryUser.DataSource = dtReceiver
        C1CountryUser.DataMember = "Name"
        C1CountryUser.DataTextField = "Name"
        C1CountryUser.DataValueField = "ID"
        C1CountryUser.DataBind()

        C1CountryOrigin.DataSource = dtDonor
        C1CountryOrigin.DataMember = "Name"
        C1CountryOrigin.DataTextField = "Name"
        C1CountryOrigin.DataValueField = "ID"
        C1CountryOrigin.DataBind()

        C1Manufacturer.Text = dtManufacturer.Rows(ViewState("CurrentRecord")).Item("Name")

‘*************************************************************
'Screen 2


        Dim XdRotationMin As New Xml.XmlDocument
        Dim RotationMinID As String
        Dim RotationMinID2 As String
   
        XdRotationMin.Load(Server.MapPath("RotationMin.xml"))

        Dim dtRotationMin As New DataTable
        dtRotationMin.Columns.Add(New DataColumn("ID"))
        dtRotationMin.Columns.Add(New DataColumn("Name"))

       For Each xnLink As Xml.XmlNode In selectedNodes
        ManufacturerID = xnLink.SelectSingleNode("Manufacturer_ID").InnerText
        For Each xnLinkB As Xml.XmlNode In xdlinkB.SelectNodes("/Root/LinkA[LinkAID='" & LinkID2 & "']")
                RotationMinID = xnLinkB.SelectSingleNode("RotationMin_ID").InnerText
                For Each xnRotationMin As Xml.XmlNode In XdRotationMin.SelectNodes("/Root/RotationMinTable[RotationMin_ID='" & RotationMinID & "']")
                    RotationMinID2 = xnRotationMin.SelectSingleNode("RotationMin_ID").InnerText
                    Name = xnRotationMin.SelectSingleNode("RotationMin").InnerText
                    dtRotationMin.Rows.Add({RotationMinID2, Name})
                Next
            Next

      Next


       
        C1RotationMin.Text = dtRotationMin.Rows(ViewState("CurrentRecord")).Item("Name")
    End Sub

Author

Commented:
I created a new updategrid method below, it seems to work when I separate the code to display data in each screen at a time, how do I set a breakpoint to see each screen at a time while the code is executing? I tried setting a message box after the code for screen1 but  it seems like the entire code needs to execute before the information is displayed on the form.  

 Private Sub updategrid2()
        Dim ManufacturerID As String
        Dim ManufacturerID2 As String
        Dim astrixState As Integer
        astrixState = 0
        Dim xdManufacturer As New Xml.XmlDocument
        Dim xdDonor As New Xml.XmlDocument
        Dim xdlink As New Xml.XmlDocument, xdlinkA As New Xml.XmlDocument, xdlinkB As New Xml.XmlDocument, xdReceiver As New Xml.XmlDocument, Link_ID As String, ReceiverID As String, ReceiverID2 As String, DonorID As String, DonorID2 As String, Name As String
        xdlink.Load(Server.MapPath("LinkSSADB.xml"))
        xdlinkA.Load(Server.MapPath("LinkA.xml"))
        xdlinkB.Load(Server.MapPath("LinkB.xml"))
        xdReceiver.Load(Server.MapPath("CountryUser.xml"))
        xdDonor.Load(Server.MapPath("CountryUser.xml"))
        xdManufacturer.Load(Server.MapPath("Manufacturer.xml"))

        Dim allSelectionString1 As String = ""
        For itemCounter As Integer = 0 To C1ACountryUser.Items.Count - 1
            If C1ACountryUser.Items(itemCounter).Selected Then
                If allSelectionString1 <> "" Then allSelectionString1 &= " or "
                allSelectionString1 &= "contains(concat(',', CountryUser_ID, ','), '," & C1ACountryUser.Items(itemCounter).Value & ",')"
            End If
        Next
        Dim allSelectionString2 As String = ""
        For itemCounter As Integer = 0 To C1ACountryOrigin.Items.Count - 1
            If C1ACountryOrigin.Items(itemCounter).Selected Then
                If allSelectionString2 <> "" Then allSelectionString2 &= " or "
                allSelectionString2 &= "contains(concat(',', CountryOrigin_ID, ','), '," & C1ACountryOrigin.Items(itemCounter).Value & ",')"
            End If
        Next
        Dim allSelectionString3 As String = ""
        Dim allSelectionString4 As String = ""
        If C1Manufacturer.Text <> "" Then
            Dim ManufacturerFound As String = ""
            For Each xnManufacturer As Xml.XmlNode In xdManufacturer.SelectNodes("/Root/ManufacturerTable[contains(Manufacturer, '" & C1Manufacturer.Text & "')]")
                If allSelectionString4 <> "" Then allSelectionString4 &= " or "
                allSelectionString4 &= "contains(concat(',', Manufacturer_ID, ','), '," & xnManufacturer.SelectSingleNode("Manufacturer_ID").InnerText & ",')"
                '' allSelectionString4 &= "contains(concat(Manufacturer_ID), '," & xnManufacturer.SelectSingleNode("Manufacturer_ID").InnerText & ",')"
                If ManufacturerFound <> "" Then ManufacturerFound &= ", "
                ManufacturerFound &= xnManufacturer.SelectSingleNode("Manufacturer").InnerText & " (id " & xnManufacturer.SelectSingleNode("Manufacturer_ID").InnerText & ")"
            Next
            If ManufacturerFound = "" Then
                Label14.Text = "Manufacturer '" & C1Manufacturer.Text & "' not found."
            Else
                Label14.Text = ManufacturerFound
            End If
        End If
        '******************************************************************************************************


        Dim dtReceiver As New DataTable
        dtReceiver.Columns.Add(New DataColumn("ID"))
        dtReceiver.Columns.Add(New DataColumn("Name"))

        Dim dtDonor As New DataTable
        dtDonor.Columns.Add(New DataColumn("ID"))
        dtDonor.Columns.Add(New DataColumn("Name"))


        Dim dtManufacturer As New DataTable
        dtManufacturer.Columns.Add(New DataColumn("ID"))
        dtManufacturer.Columns.Add(New DataColumn("Name"))


        Dim iCount As Integer = 0

        Dim allSelectionStringOverall As String = ""

        For Each selString As String In {allSelectionString1, allSelectionString2, allSelectionString3}
            If selString <> "" Then
                If allSelectionStringOverall <> "" Then allSelectionStringOverall &= " and "
                If astrixState = 1 Then allSelectionStringOverall &= "not "
                allSelectionStringOverall &= "(" & selString & ")"
            End If
        Next
        If allSelectionStringOverall <> "" Then allSelectionStringOverall = "[" & allSelectionStringOverall & "]"
        Previous.Enabled = False
        NextA.Enabled = False

        Dim selectedNodes As Xml.XmlNodeList = xdlink.SelectNodes("/Root/LinkA" & allSelectionStringOverall)

        'Screen 1
        For Each xnLink As Xml.XmlNode In selectedNodes
            Link_ID = xnLink.SelectSingleNode("LinkAID").InnerText
            ReceiverID = xnLink.SelectSingleNode("CountryUser_ID").InnerText
            DonorID = xnLink.SelectSingleNode("CountryOrigin_ID").InnerText
            ' ManufacturerID = xnLink.SelectSingleNode("Manufacturer_ID").InnerText

            iCount += 1
            If iCount < ViewState("CurrentRecord") Then
                Previous.Enabled = True
            ElseIf iCount > ViewState("CurrentRecord") Then
                NextA.Enabled = True
            Else
                MsgBox("icount")
                MsgBox(iCount)
                Label15.Text = " ( " & iCount & "/ " & selectedNodes.Count & ") "
                For Each xnReceiver As Xml.XmlNode In xdReceiver.SelectNodes("/Root/CountryUserTable[contains('," & ReceiverID & ",', concat(',', CountryUser_ID, ','))]")
                    ReceiverID2 = xnReceiver.SelectSingleNode("CountryUser_ID").InnerText
                    Name = xnReceiver.SelectSingleNode("CountryUser").InnerText
                    dtReceiver.Rows.Add({ReceiverID2, Name})
                Next
                For Each xnDonor As Xml.XmlNode In xdDonor.SelectNodes("/Root/CountryUserTable[contains('," & DonorID & ",', concat(',', CountryUser_ID, ','))]")
                    DonorID2 = xnDonor.SelectSingleNode("CountryUser_ID").InnerText
                    Name = xnDonor.SelectSingleNode("CountryUser").InnerText
                    dtDonor.Rows.Add({DonorID2, Name})
                Next


                LinkID2 = xnLink.SelectSingleNode("LinkAID").InnerText


                ' For Each xnLinkA As Xml.XmlNode In xdlinkA.SelectNodes("/Root/LinkA[LinkAID='" & LinkID2 & "']")
                'ManufacturerID = xnLinkA.SelectSingleNode("Manufacturer_ID").InnerText
                'For Each xnManufacturer As Xml.XmlNode In xdManufacturer.SelectNodes("/Root/ManufacturerTable[Manufacturer_ID='" & ManufacturerID & "']")
                'ManufacturerID2 = xnManufacturer.SelectSingleNode("Manufacturer_ID").InnerText
                'Name = xnManufacturer.SelectSingleNode("Manufacturer").InnerText
                'dtManufacturer.Rows.Add({ManufacturerID2, Name})
                'Next
                'Next
            End If

        Next

        'Screen1

        C1CountryUSer.DataSource = dtReceiver
        C1CountryUSer.DataMember = "Name"
        C1CountryUSer.DataTextField = "Name"
        C1CountryUSer.DataValueField = "ID"
        C1CountryUSer.DataBind()

        C1CountryOrigin.DataSource = dtDonor
        C1CountryOrigin.DataMember = "Name"
        C1CountryOrigin.DataTextField = "Name"
        C1CountryOrigin.DataValueField = "ID"
        C1CountryOrigin.DataBind()

        'C1Manufacturer.Text = dtManufacturer.Rows(ViewState("CurrentRecord")).Item("Name")

        '*************************************************************
        'Screen 2

        Dim XdRotationMin As New Xml.XmlDocument
        Dim RotationMinID As String
        Dim RotationMinID2 As String

        XdRotationMin.Load(Server.MapPath("RotationMin.xml"))

        Dim dtRotationMin As New DataTable
        dtRotationMin.Columns.Add(New DataColumn("ID"))
        dtRotationMin.Columns.Add(New DataColumn("Name"))

        For Each xnLink As Xml.XmlNode In selectedNodes
            For Each xnLinkB As Xml.XmlNode In xdlinkB.SelectNodes("/Root/LinkA[LinkAID='" & LinkID2 & "']")
                RotationMinID = xnLinkB.SelectSingleNode("RotationMin_ID").InnerText
                For Each xnRotationMin As Xml.XmlNode In XdRotationMin.SelectNodes("/Root/RotationMinTable[RotationMin_ID='" & RotationMinID & "']")
                    RotationMinID2 = xnRotationMin.SelectSingleNode("RotationMin_ID").InnerText
                    Name = xnRotationMin.SelectSingleNode("RotationMin").InnerText
                    dtRotationMin.Rows.Add({RotationMinID2, Name})
                Next
            Next

        Next
        C1RotationMin.Text = dtRotationMin.Rows(ViewState("CurrentRecord")).Item("Name")
Robert SchuttSoftware Engineer

Commented:
I didn't get the project you posted to work yesterday and haven't had time today.

As for your last posts:

> There is no row at position 8.

That's correct, the index is zero based, so always subtract 1 if you have an index that runs from 1 to 8.

> is there a way to execute this metho only when the users presses the Search and Navigation button?

Yes, but the way I see it you have to put the correct contents in certain controls every time the page is loaded. I cannot stress enough that you have to look into the basic structure of an ASP.NET application and Page Life Cycle on that page I posted earlier. It's not the same as in a windows forms application where you put something in and it will stay in until you take it out. In ASP.NET when there is a page request, the page is basically reconstructed from scratch every time. So that means every time you click a button or change a control that has its AutoPostback set, the code is run and the full page must be constructed.

> it seems like the entire code needs to execute before the information is displayed on the form.

Yes, that's because the browser can only update when the page has been fully constructed. For speed I suggested earlier to use the MultiView1.ActiveViewIndex to run only the code that you need to fill the controls that are visible on the current View.

I hope I won't confuse you further but there is another option altogether and that is having a client-side selection of Views. I haven't used this in ASP.NET yet but have used 'old school' javascript to hide and display divs, I guess it would be similar to that. In that case you construct the page with all the Views once, don't use AutoPostback and asp:Buttons for view selection but client-side (javascript) functions to select views.

Author

Commented:
Hi,

I'm not certain where to reduce the index, i tried the code below but ny Next button still doesn't disble when i get to the last record. Also my view starts at id = 2 rather than id1, not sure if this is alsp part of the problem.


  If iCount < ViewState("CurrentRecord") Then
                Previous.Enabled = True
            ElseIf iCount > ViewState("CurrentRecord - 1") Then
                NextA.Enabled = True
            Else


I will modify the code in the click evet of the controls that should not execure the updategrid method.


How do I  use the MultiView1.ActiveViewIndex to run only the code that you need to fill the controls that are visible on the current View?

How do I replace the MultiView control with Div tags with a table and panels inside a table, and how do I move to different Div tags similar to the way I move to different Views?

Below is an example of the format of the first 4 view, can I simply remove the MultiView and View tags and work with the Div tag? and write new code to move to different Div tags. I believe it will also be easier to print without the Multiview tag control.

 <asp:MultiView ID="MultiView1" runat="server" ActiveViewIndex="0">
            <asp:View ID="View1" runat="server">
            <div>
        <table class="center1" bgcolor="Silver">
           <tr>
               <td class="style1171">
                      <asp:Panel ID="Panel5" runat="server" Width="550px" BorderStyle="Solid"
                          Height="608px">
                            <table border="1">
                            <tr>
                             <td class="style988" colspan="3"bgcolor="Yellow" align = "center">
                     </td>
                      </tr>
                         </table>
                </asp:Panel>
                </table>
                </div>
             </asp:View>
              <asp:View ID="View2" runat="server">
              <div>
              <table class="center1" bgcolor="Silver">
              <tr>
               <td class="style1171">
                      <asp:Panel ID="Panel5" runat="server" Width="550px" BorderStyle="Solid"
                          Height="608px">
                            <table border="1">
                            <tr>
                             <td class="style988" colspan="3"bgcolor="Yellow" align = "center">
                     </td>
                      </tr>
                        </table>
                </asp:Panel>
                </table>
                </div>
             </asp:View>
          <asp:View ID="View3" runat="server">
              <div>
              <table class="center1" bgcolor="Silver">
              <tr>
               <td class="style1171">
                      <asp:Panel ID="Panel5" runat="server" Width="550px" BorderStyle="Solid"
                          Height="608px">
                            <table border="1">
                            <tr>
                             <td class="style988" colspan="3"bgcolor="Yellow" align = "center">
                     </td>
                      </tr>
                          </tr>
                          </table>
                           </asp:Panel>
                          </td>
                    </tr>
                </table>
           </div>
             </asp:View>
          <asp:View ID="View4" runat="server">
              <div>
              <table class="center1" bgcolor="Silver">
              <tr>
               <td class="style1171">
                      <asp:Panel ID="Panel5" runat="server" Width="550px" BorderStyle="Solid"
                          Height="608px">
                            <table border="1">
                            <tr>
                             <td class="style988" colspan="3"bgcolor="Yellow" align = "center">
                     </td>
                      </tr>
                </table>
                </asp:Panel>
                </table>
                </div>
             </asp:View>
          </asp:MultiView>

Thanks,

V.
Robert SchuttSoftware Engineer

Commented:
> I'm not certain where to reduce the index

I meant subtract 1 in code like this:

C1RotationMin.Text = dtRotationMin.Rows(ViewState("CurrentRecord") - 1).Item("Name")

I haven't had time to look at this and will be out tomorrow and the day after (which is a national holiday here).

All the code you post doesn't help because I can't test it out probably due to our different C1 packages.

I still don't get the feeling you're investing in learning about ASP.NET structure and clinging to your knowledge about winforms development which does not apply here.

The "client-side MultiView" could work and yes, could also mean easier control over printing BUT will require a major re-write, not just changing a few tags.

Maybe it's better to close this question off (by now, it sounds harsh, but it's not about the points anymore), try to post a new, confined and clear question and hope someone will pick it up with more specific experience.

Author

Commented:
OK,  I will close this question..  Thanks a lot for all your time in helping me resolve my initial issue. I've learned a lot from you. I will spend more time in learnng ASP.NET, I have a lot more to learn in order to complete this project.

Author

Commented:
Hi,

The code below worked.

C1RotationMin.Text = dtRotationMin.Rows(ViewState("CurrentRecord") - 1).Item("Name")

If you get a chance can you please help me with the question below.

How do I  use the MultiView1.ActiveViewIndex to run only the code that I need to fill the controls that are visible on View2? View1 is used to search the data and the results starts in View2. I will than call a method to populate data in the remaining Views. Meanwhile, as mentioned I will close this case.

Thank You,

Victor

Author

Commented:
THANK YOU!
Robert SchuttSoftware Engineer

Commented:
Ok, let's close off with that.

What I meant is this: the UpgradeGrid function does some processing that is needed in every case, like filling datasets and selecting from the Links.xml file. But it also fills some controls that are only needed when displaying View2, and some other controls that are only needed when displaying View3. So nothing complicated, just use 'if' statements to process only those datasets you are going to assign as source to the controls that are going to be displayed.

But if you're thinking in application structure like making a windows form application that may not make sense at all. Therefore you need to understand the way the page is built, the way the user interacts with your application, which parts you want server-based and which parts could be more useful client-based. These are not always things somebody else can tell you, but depend on your application design (for example; do you need the most recent data all the time or can you do the selection once and show that in all the screens) and how you expect it to be used (internet or intranet for example).

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial