Discussion:
DataGrid and MS Access database
(too old to reply)
Joe
2005-02-27 21:39:02 UTC
Permalink
I have a datagrid on a web form and I am setting the datasource in Page_Load
Event and there are no errors generated, I can interrogate the DataTable and
it returns row count, column count, data in rows, etc., but the DataGrid
itself will NOT appear at all on the web form. Anybody know why?

Thanks.

Joe
**********************

Dim oConn As New OleDbConnection
oConn.ConnectionString = ConnString 'generated outside Page_Load
oConn.Open()

Dim sSQL As String = "select * from REGISTRATION"

Dim da As OleDbDataAdapter = New OleDbDataAdapter(sSQL, oConn)

Dim ds As DataSet = New DataSet
da.Fill(ds, "REGISTRATION")
Me.DataGrid1.DataSource = ds.Tables("REGISTRATION")
lblStatus.Text = ds.Tables(0).TableName & ";Columns = " &
ds.Tables(0).Columns.Count.ToString
lblStatus.Visible = True
--
Joe Baker
Scott M.
2005-02-27 22:02:28 UTC
Permalink
Add this to the end:

DataGrid1.DataBind
Post by Joe
I have a datagrid on a web form and I am setting the datasource in Page_Load
Event and there are no errors generated, I can interrogate the DataTable and
it returns row count, column count, data in rows, etc., but the DataGrid
itself will NOT appear at all on the web form. Anybody know why?
Thanks.
Joe
**********************
Dim oConn As New OleDbConnection
oConn.ConnectionString = ConnString 'generated outside Page_Load
oConn.Open()
Dim sSQL As String = "select * from REGISTRATION"
Dim da As OleDbDataAdapter = New OleDbDataAdapter(sSQL, oConn)
Dim ds As DataSet = New DataSet
da.Fill(ds, "REGISTRATION")
Me.DataGrid1.DataSource = ds.Tables("REGISTRATION")
lblStatus.Text = ds.Tables(0).TableName & ";Columns = " &
ds.Tables(0).Columns.Count.ToString
lblStatus.Visible = True
--
Joe Baker
Scott M.
2005-02-27 22:07:38 UTC
Permalink
Actually, to be more precise:

If Not IsPostBack Then
DataGrid1.DataBind
End If
Post by Scott M.
DataGrid1.DataBind
Post by Joe
I have a datagrid on a web form and I am setting the datasource in Page_Load
Event and there are no errors generated, I can interrogate the DataTable and
it returns row count, column count, data in rows, etc., but the DataGrid
itself will NOT appear at all on the web form. Anybody know why?
Thanks.
Joe
**********************
Dim oConn As New OleDbConnection
oConn.ConnectionString = ConnString 'generated outside Page_Load
oConn.Open()
Dim sSQL As String = "select * from REGISTRATION"
Dim da As OleDbDataAdapter = New OleDbDataAdapter(sSQL, oConn)
Dim ds As DataSet = New DataSet
da.Fill(ds, "REGISTRATION")
Me.DataGrid1.DataSource = ds.Tables("REGISTRATION")
lblStatus.Text = ds.Tables(0).TableName & ";Columns = " &
ds.Tables(0).Columns.Count.ToString
lblStatus.Visible = True
--
Joe Baker
Joe
2005-02-28 00:09:03 UTC
Permalink
ah, yes. It's the simple things... that worked. Thanks Scott.
Post by Scott M.
If Not IsPostBack Then
DataGrid1.DataBind
End If
Post by Scott M.
DataGrid1.DataBind
Post by Joe
I have a datagrid on a web form and I am setting the datasource in Page_Load
Event and there are no errors generated, I can interrogate the DataTable and
it returns row count, column count, data in rows, etc., but the DataGrid
itself will NOT appear at all on the web form. Anybody know why?
Thanks.
Joe
**********************
Dim oConn As New OleDbConnection
oConn.ConnectionString = ConnString 'generated outside Page_Load
oConn.Open()
Dim sSQL As String = "select * from REGISTRATION"
Dim da As OleDbDataAdapter = New OleDbDataAdapter(sSQL, oConn)
Dim ds As DataSet = New DataSet
da.Fill(ds, "REGISTRATION")
Me.DataGrid1.DataSource = ds.Tables("REGISTRATION")
lblStatus.Text = ds.Tables(0).TableName & ";Columns = " &
ds.Tables(0).Columns.Count.ToString
lblStatus.Visible = True
--
Joe Baker
Loading...