Databind () on gridview not working VB.net ASP.Net

I have a datatable with 10 checked rows named dtable. I am trying to bind it to a gridview and nothing appears on my asp.net page. Why aren't these relatively simple few lines populating my gridview?

    Dim con As SqlConnection = Nothing
    Dim dTable As DataTable
    Dim dataAdapter As SqlDataAdapter
    Dim sqlcmd As String
    .......
    dTable = New DataTable
    dataAdapter = New SqlDataAdapter(sqlcmd, con)
    dataAdapter.Fill(dTable)

    'DATATABLE at this point has 10 rows in it, I verified that at runtime

    gvUnitSystem.DataSource = dTable
    gvUnitSystem.DataBind()

End Sub

      

What am I doing wrong?

0


source to share


3 answers


Are you sure the GridView is set to AutoGenerateColumns?



gvUnitSystem.AutoGenerateColumns = True

      

+3


source


It looks great. Are you auto-filling the columns, or are you manually adding columns to the designer? If it is the latter, it is possible that none of the fields in the column match the fields in your table.



0


source


You need to install con (connection string).

0


source







All Articles