Click here to Skip to main content
15,949,741 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,

I have 2 arraylist . Arraylist Name and Arraylist URL..I need to add this to the Datatable.
Arraylist Name is Added to the Datatable for column "Name" ..But i am not sure how to add the arralist URL to the same datatable for column "URL"

Here is wat i tried
VB
dt.Columns.Add("Name")

       For i As Integer = 0 To Name.Count - 1
           Dim dr As DataRow = Nothing
           dr = dt.NewRow()
           dr.Item(0) = Name.Item(i)
           dt.Rows.Add(dr)
       Next


Please help.

Thanks.
Posted

1 solution

Let's see an example.If you have lists a1,a2,a3 you can use join and merge the data by UserID like..
VB
Dim a1 = New Object() {New With {.userID = 1, .firstName = "first Name", .lastName = "Last Name"}}.ToList()
Dim a2 = New Object() {New With {.userID = 1, .address = "address"}}.ToList()
Dim a3 = New Object() {New With {.userID = 1, .productID = "Product ID", .ProducName = "Product Name"}}.ToList()
Dim results = (From a In a1
    Join b In a2 On a.userID Equals b.userID
    Join c In a3 On a.userID Equals c.userID
    Select New With _
    {
        a.userID,
        a.firstName,
        a.lastName,
        b.address,
        c.productID,
        c.ProducName
    }).ToList()
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900