Datagrid won't display results

vbasqlprogrammer used Ask the Experts™

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,

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

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

Open in new window

Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
it think this line is wrong;
gvfiles.DataSource() = mydatatable => must be => gvfiles.DataSource = mydatatable


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?
>>Dim gvfiles As New GridView

r u creating the gridview dynamically?

if so, u should add the created gridview to page control collection.



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

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