Click here to Skip to main content
15,885,278 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,
I have a webservice with the following fields,

<moduleno>M17AB
<fpono>818-1700-E
<process>SEWING
<Style>98966/ 1132e03817</Style>
<colour>Black (54A2)
<qty>1560
<requireddate>30 Aug 2013
<requestedno>GDI-RMWH-23401
<wh>RMWH

I need to have table transposed and the FPONo, to apear as the follwoing grid,

DAY MOD 1 MOD 2 MOD 3 MOD 4 MOD 5 MOD 6 MOD 7 MOD 8 MOD 9 MOD 10 MOD 11 MOD 12 MOD 13 MOD 14 MOD 15 MOD 16 MOD 17 MOD 18 MOD 19 MOD 20
01-Apr 1056A                                      
02-Apr   1076H                                    
03-Apr 1064D 1025C                                    
    1025D                                    
04-Apr 1064E                                      
05-Apr   1025F                                    
06-Apr 1077A                                      
07-Apr 1026B                                      
08-Apr                                        



tried the following but still cant get it working,

VB
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    'Try
    Dim objWebService1 As New ServiceReference2.ServiceSoapClient("ServiceSoap1")
    ds = objWebService1.GetFPPOGDIForDashboard("UN", "PW", "com")
    Dim objDv As New DataView(ds.Tables(0), "Process='SEWING'", "ModuleNo", DataViewRowState.CurrentRows)
    Dim test As New DataView(objDv.ToTable, "WH='RMWH'", "ModuleNo", DataViewRowState.CurrentRows)
    'Dim test2 As New DataView(PivotTable(test.ToTable()))
    GridView1.DataSource = GenerateTransposedTable(test.ToTable)
    GridView1.DataBind()
    GridView1.AllowSorting = True
    Response.AppendHeader("Refresh", "360")
    'Catch ex As Exception

    'End Try
End Sub

 Private Function GenerateTransposedTable(inputTable As DataTable) As DataTable
        Dim outputTable As New DataTable()

        ' Add columns by looping rows

        ' Header row's first column is same as in inputTable
        outputTable.Columns.Add(inputTable.Columns(0).ColumnName.ToString())

        ' Header row's second column onwards, 'inputTable's first column taken

        For Each inRow As DataRow In inputTable.Rows

            Dim newColName As String = inRow(0).ToString()
            Try
                outputTable.Columns.Add(newColName)
            Catch ex As Exception
            End Try

        Next
        outputTable.Columns(0).ColumnName = " Date  "


        ' Add rows by looping columns        
        For rCount As Integer = 1 To inputTable.Rows.Count
            Dim newRow As DataRow = outputTable.NewRow()
            newRow(0) = inputTable.Rows(rCount - 1).Item(6).ToString()
            For cCount As Integer = 1 To outputTable.Columns.Count

                For rCount1 As Integer = 1 To inputTable.Rows.Count
                    If outputTable.Columns(cCount - 1).ToString = inputTable.Rows(rCount1 - 1).Item(0).ToString Then
                        newRow(cCount - 1) = inputTable.Rows(rCount1 - 1).Item(1).ToString
                    End If
                Next
            Next


            'For inRow As Integer = 1 To inputTable.Rows.Count
            '    Try
            '        newRow(inRow + 1) = inputTable.Rows(inRow + 1).Item(6).ToString()
            '    Catch
            '    End Try
            'Next


            '    ' First column is inputTable's Header row's second column
            '    newRow(0) = inputTable.Columns(rCount).ColumnName.ToString()
            '    For cCount As Integer = 0 To inputTable.Rows.Count - 1
            '        Dim colValue As String = inputTable.Rows(cCount)(rCount).ToString()
            '        Try
            '            newRow(cCount + 1) = colValue
            '        Catch ex As Exception
            '        End Try
            ' Next
            outputTable.Rows.Add(newRow)
        Next

        Return outputTable
    End Function


please do let me know how to get this done
thanks in advance.
Posted

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