I have two GridViews, the first works fine as I defined the datasource when I dropped it onto the asp page via visual studio and I specified the table to use.
The other GridView (dgvParams below) has just been dropped onto the asp page and I want to use it at run time:
Imports System.Data
Imports System.Data.SqlClient
Imports myDataBase
Partial Class TestWeb
Inherits System.Web.UI.Page
Dim data As New cDatabase
Public Sub New()
End Sub
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
dgvParams = New GridView
LoadParamsGrid()
End Sub
Public Sub LoadParamsGrid()
' Create the dataset
Dim strCon As String = data.DBConn.ConnectionString
Dim strSQL As String = "dbo.GetParameters"
Dim dataAdapter As New SqlDataAdapter(strSQL, strCon)
Dim table As New DataTable
Try
dataAdapter.Fill(table)
Catch ex As Exception
' try again
dataAdapter.Fill(table)
End Try
dgvParams.DataSource = table
dgvParams.DataBind()
End Sub
End Class
When I step through the code I can see row and column counts are as expected and call "dgvParams.DataSource = table".
I think I am missing another step somewhere so that I can physically see the data on the GridView? Any suggestions?
Thank you