N
nicholas
think it's rather simple...but don't know how.
Showing bound data on a page is quite simple if you use a datagrid,
datalist, etc.
But I just want to put some databound items on my page, without datagrid,
etc.
(And there will be just 1 record selected, so no repeating problem)
So, here is what I did to connect to the database and select the appropriate
row:
####### code start #####
Sub Page_Load(sender As Object, e As EventArgs)
'Load all info from the database:
'define where the connectionstring is here:
Dim MyConnectionString as String =
ConfigurationSettings.AppSettings("ConnectionString")
'make the connection
Dim MyConnection as New SqlConnection(MyConnectionString)
'deine some variable needed for the SQL-string here:
Dim TheSelectedShopID as String = Request.QueryString("shopID")
'define the SQL-string here
Dim SQLstring As String
SQLstring = "SELECT * FROM tbl_shops WHERE shopID = " +
TheSelectedShopID
'create the DataAdapter
Dim MyAdapter As New SqlDataAdapter(SqlString, MyConnection)
'create and fill the datatable
Dim MyDataTable as new Datatable
MyAdapter.Fill(MyDataTable)
'create and fill the dataset
Dim MyDataSet as new Dataset
MyAdapter.Fill(MyDataSet)
'create dataview
Dim MyView as DataView = MyDataSet.tables(0).defaultview
End Sub
############# end of code ########
So now, in my html code I would like to place something like this:
the name of the shop is <%# MyView.FieldValue("shopnameEN", Container) %>
But I get an error saying that MyView is not declared.
Must do something wrong here..?
btw. the connection works.
because if I use this it works:
######
'select the row in the datatable
Dim CurrentRow As DataRow
CurrentRow = myDataTable.Rows(0)
'set the texts in the page to the content of the datarow
shopname.text = CurrentRow("shopnameEN")
#####
But I don't want to do it this way...
THX for advice.
Nic
Showing bound data on a page is quite simple if you use a datagrid,
datalist, etc.
But I just want to put some databound items on my page, without datagrid,
etc.
(And there will be just 1 record selected, so no repeating problem)
So, here is what I did to connect to the database and select the appropriate
row:
####### code start #####
Sub Page_Load(sender As Object, e As EventArgs)
'Load all info from the database:
'define where the connectionstring is here:
Dim MyConnectionString as String =
ConfigurationSettings.AppSettings("ConnectionString")
'make the connection
Dim MyConnection as New SqlConnection(MyConnectionString)
'deine some variable needed for the SQL-string here:
Dim TheSelectedShopID as String = Request.QueryString("shopID")
'define the SQL-string here
Dim SQLstring As String
SQLstring = "SELECT * FROM tbl_shops WHERE shopID = " +
TheSelectedShopID
'create the DataAdapter
Dim MyAdapter As New SqlDataAdapter(SqlString, MyConnection)
'create and fill the datatable
Dim MyDataTable as new Datatable
MyAdapter.Fill(MyDataTable)
'create and fill the dataset
Dim MyDataSet as new Dataset
MyAdapter.Fill(MyDataSet)
'create dataview
Dim MyView as DataView = MyDataSet.tables(0).defaultview
End Sub
############# end of code ########
So now, in my html code I would like to place something like this:
the name of the shop is <%# MyView.FieldValue("shopnameEN", Container) %>
But I get an error saying that MyView is not declared.
Must do something wrong here..?
btw. the connection works.
because if I use this it works:
######
'select the row in the datatable
Dim CurrentRow As DataRow
CurrentRow = myDataTable.Rows(0)
'set the texts in the page to the content of the datarow
shopname.text = CurrentRow("shopnameEN")
#####
But I don't want to do it this way...
THX for advice.
Nic