Hello, I'm having problems databinding a combobox.
Code:
<%@ Page Language="VB" %>
<%@ import Namespace="System.Data" %>
<%@ import Namespace="System.Data.SqlClient" %>
<script runat="server">
Function GetPriceBracket() As System.Data.DataSet
Dim connectionString As String = "server='x'; user id='sa'; password='x'; database=x"
Dim dbConnection As System.Data.IDbConnection = New System.Data.SqlClient.SqlConnection(connectionString)
Dim queryString As String = "SELECT [pricebracket].[price] FROM [pricebracket]"
Dim dbCommand As System.Data.IDbCommand = New System.Data.SqlClient.SqlCommand
dbCommand.CommandText = queryString
dbCommand.Connection = dbConnection
Dim dataAdapter As System.Data.IDbDataAdapter = New System.Data.SqlClient.SqlDataAdapter
dataAdapter.SelectCommand = dbCommand
Dim dataSet As System.Data.DataSet = New System.Data.DataSet
dataAdapter.Fill(dataSet)
Return dataSet
End Function
Sub Page_Load(Sender As Object, E As EventArgs)
comboboxid.DataSource = GetPriceBracket()
comboboxid.DataBind()
End Sub
</script>
<html>
<head>
</head>
<body style="FONT-FAMILY: arial">
<form runat="server">
<aspropDownList id="comboboxid" runat="server"></aspropDownList>
</form>
</body>
</html>
Code:
<%@ Page Language="VB" %>
<%@ import Namespace="System.Data" %>
<%@ import Namespace="System.Data.SqlClient" %>
<script runat="server">
Function GetPriceBracket() As System.Data.DataSet
Dim connectionString As String = "server='x'; user id='sa'; password='x'; database=x"
Dim dbConnection As System.Data.IDbConnection = New System.Data.SqlClient.SqlConnection(connectionString)
Dim queryString As String = "SELECT [pricebracket].[price] FROM [pricebracket]"
Dim dbCommand As System.Data.IDbCommand = New System.Data.SqlClient.SqlCommand
dbCommand.CommandText = queryString
dbCommand.Connection = dbConnection
Dim dataAdapter As System.Data.IDbDataAdapter = New System.Data.SqlClient.SqlDataAdapter
dataAdapter.SelectCommand = dbCommand
Dim dataSet As System.Data.DataSet = New System.Data.DataSet
dataAdapter.Fill(dataSet)
Return dataSet
End Function
Sub Page_Load(Sender As Object, E As EventArgs)
comboboxid.DataSource = GetPriceBracket()
comboboxid.DataBind()
End Sub
</script>
<html>
<head>
</head>
<body style="FONT-FAMILY: arial">
<form runat="server">
<aspropDownList id="comboboxid" runat="server"></aspropDownList>
</form>
</body>
</html>