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
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
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.
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.
ASKER
Anyone else have any ideas?
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
dejaanbu,
No I am not creating this dynamically. Thanks for your help. It solved the solution.
No I am not creating this dynamically. Thanks for your help. It solved the solution.
gvfiles.DataSource() = mydatatable => must be => gvfiles.DataSource = mydatatable