Forum Moderators: open
I wrote a Windows VB.NET application that uses SQL Server 2000. The application displays database records in a Data Grid element.
I would like to turn this into a Web application, and again, use Data Grid to display the records in the browser.
I have it working properly using a List Box element, but when I use the Data Grid nothing is displayed.
Am I missing some parameters, declarations or..?
Private Sub btnLoad_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLoad.Click
dt.Clear()
Dim dataAdapter As New SqlClient.SqlDataAdapter(sqlStr, connstr)
dataAdapter.Fill(dt)
dataAdapter.Dispose()
dgDisplay.DataSource = dt
End Sub
Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
Dim changes As Integer
Dim dataAdapter As New SqlClient.SqlDataAdapter(sqlStr, connstr)
Dim commandBuilder As New SqlClient.SqlCommandBuilder(dataAdapter)
changes = dataAdapter.Update(dt)
dataAdapter.Dispose()
If changes > 0 Then
MsgBox(changes & " changed rows were stored in the database.")
Else
MsgBox("no changes made.")
End If
End Sub
Is it possible to make the Web Application Data Grid identical to the Windows Application Data Grid(ie. to have the same functionality)?
If so, would it require a change in the code or is it a configuration of the Data Grid element's parameters?
I was looking at the code, and at the bottom when the example shows how to use the findcontrol method, I like to use DirectCast instead of the older CType, it is a bit faster, IMO.