T
Tor Inge Rislaa
Databinding programmatically
In my webform I have the code below in the form_load procedure.
On the webform I have a GridView control. My question is simply how to bind
the GridView to the datasource in the code programatically.
Dim cnn As OleDbConnection
Dim strConnection As String
strConnection = "Provider=sqloledb;Data Source=myServer;Initial
Catalog=Intranett;;Persist Security Info=True;User
ID=sa;Password=myPassword"
cnn = New OleDbConnection
cnn.ConnectionString = strConnection
Dim myDataSet As DataSet
myDataSet = New DataSet("Artikler")
Dim myDataAdapter As OleDbDataAdapter
myDataAdapter = New OleDbDataAdapter("", cnn)
Dim myCommand As OleDbCommand
myCommand = New OleDbCommand("Select * from Artikler")
myDataAdapter.SelectCommand = CommandObject
myDataAdapter.SelectCommand.Connection = cnn
myDataAdapter.Fill(myDataSet, "Artikler")
TIRislaa
In my webform I have the code below in the form_load procedure.
On the webform I have a GridView control. My question is simply how to bind
the GridView to the datasource in the code programatically.
Dim cnn As OleDbConnection
Dim strConnection As String
strConnection = "Provider=sqloledb;Data Source=myServer;Initial
Catalog=Intranett;;Persist Security Info=True;User
ID=sa;Password=myPassword"
cnn = New OleDbConnection
cnn.ConnectionString = strConnection
Dim myDataSet As DataSet
myDataSet = New DataSet("Artikler")
Dim myDataAdapter As OleDbDataAdapter
myDataAdapter = New OleDbDataAdapter("", cnn)
Dim myCommand As OleDbCommand
myCommand = New OleDbCommand("Select * from Artikler")
myDataAdapter.SelectCommand = CommandObject
myDataAdapter.SelectCommand.Connection = cnn
myDataAdapter.Fill(myDataSet, "Artikler")
TIRislaa