Click here to Skip to main content
15,888,264 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello

I'm trying to flip Dataset so as to flip my gridview in ASP.NET using VB.NET

I'm using this code

Public Function FlipDataSet(ByVal my_DataSet As DataSet) As DataSet
        Dim ds As New DataSet()


        For Each dt As DataTable In my_DataSet.Tables
            Dim table As New DataTable()

            For i As Integer = 0 To dt.Rows.Count
                table.Columns.Add(Convert.ToString(i))
            Next i
            Dim r As DataRow
            For k As Integer = 0 To dt.Columns.Count - 1
                r = table.NewRow()
                r(0) = dt.Columns(k).ToString()
                For j As Integer = 1 To dt.Rows.Count
                    r(j) = dt.Rows(j - 1)(k)
                Next j
                table.Rows.Add(r)
            Next k

            ds.Tables.Add(table)
        Next dt

        Return ds
    End Function



The error is on ( convert )

as show in this image

http://q8sch.net/upload/convert.png[^]
Posted
Comments
Tomas Takac 14-Nov-15 8:11am    
Next time please do not post a picture but paste the error message as text. Now try i.ToString() and you should be fine.
moghastar 14-Nov-15 10:29am    
Thank you for your advise , and solution
Wombaticus 14-Nov-15 8:18am    
Well it looks like you have a function - maybe an event handler for a button? - somewhere in your code called "Convert", which is confusing things...

1 solution

You have protected method somewhere in the class that is named Convert this hides the Convert class. You can either use full namespace to tell the compiler where to find Convert:
VB
System.Convert.ToString(i)

or simply call ToString on the integer value directly:
VB
i.ToString()
 
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