Link to home
Start Free TrialLog in
Avatar of vbasqlprogrammer
vbasqlprogrammer

asked on

Datagrid won't display results

Hi,

I have a datagrid which is populated after i run a function which returns a datatable.  However the gridview will not display the results.  I have attached the code.  Can any body lend us a hand?  

I have test the datatable to see if there is data in it by using msgbox to display data from the various rows so I know there is data there.

I have posted the code for your perousal.

Kind Regards,

Tim
Protected Sub Button3_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button3.Click
        Dim Token As String = Me.resultlabel.Text
        Dim gvfiles As New GridView
        Dim mydatatable As New Data.DataTable






        mydatatable = returnitems(Token, "\CHRISTADSTUDIES\Studies") 'this functions returns a datatable
        Dim row1 As Data.DataRow = mydatatable.Rows(2)
        MsgBox(row1(0).ToString) 'test to make sure data is in the table
        gvfiles.AutoGenerateColumns = True
        gvfiles.DataSource() = mydatatable
        gvfiles.DataBind()

        errorlabel.Text = "completed" 'A label I used to make sure the code ran thru to the end.
    End Sub

Open in new window

Avatar of el_aristo
el_aristo

it think this line is wrong;
gvfiles.DataSource() = mydatatable => must be => gvfiles.DataSource = mydatatable
Avatar of vbasqlprogrammer

ASKER

Hi el aristo,

Yes you are right, just that in my trying everything I just decided to add it to see what it would do.  To me there is nothing wrong with the code, and so I just decided to add the brackets thinking it may to something.
Anyone else have any ideas?
ASKER CERTIFIED SOLUTION
Avatar of Deja Anbu
Deja Anbu
Flag of Oman image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
dejaanbu,

No I am not creating this dynamically.  Thanks for your help.  It solved the solution.