R
RAB
I have the following code:
<%@ Page Language="VB" %>
<script runat="server">
Function GetName() As System.Data.IDataReader
Dim connectionString As String = 'path to datasource
Dim dbConnection As System.Data.IDbConnection = New
System.Data.OleDb.OleDbConnection
(connectionString)
Dim queryString As String = "SELECT [Customer].[ID],
[Customer].[LName], [Customer].[FName] FROM
[Customer]"
Dim dbCommand As System.Data.IDbCommand = New
System.Data.OleDb.OleDbCommand
dbCommand.CommandText = queryString
dbCommand.Connection = dbConnection
dbConnection.Open
Dim dataReader As System.Data.IDataReader =
dbCommand.ExecuteReader
(System.Data.CommandBehavior.CloseConnection)
Return dataReader
End Function
Sub Page_Load(sender As Object, e As EventArgs)
Listbox1.datasource = GetName()
Listbox1.databind()
End Sub
</script>
<html>
<head>
</head>
<body>
<form runat="server">
<p>
</p>
<p>
<asp:ListBox id="ListBox1" runat="server"
DataTextField="LName" DataValueField="ID"></asp:ListBox>
</p>
<p>
<!-- Insert content here -->
</p>
</form>
</body>
</html>
If I wanted to populate my dropdownListbox with first and last name,
how would I code this?
Thanks,
RABMissouri2007
<%@ Page Language="VB" %>
<script runat="server">
Function GetName() As System.Data.IDataReader
Dim connectionString As String = 'path to datasource
Dim dbConnection As System.Data.IDbConnection = New
System.Data.OleDb.OleDbConnection
(connectionString)
Dim queryString As String = "SELECT [Customer].[ID],
[Customer].[LName], [Customer].[FName] FROM
[Customer]"
Dim dbCommand As System.Data.IDbCommand = New
System.Data.OleDb.OleDbCommand
dbCommand.CommandText = queryString
dbCommand.Connection = dbConnection
dbConnection.Open
Dim dataReader As System.Data.IDataReader =
dbCommand.ExecuteReader
(System.Data.CommandBehavior.CloseConnection)
Return dataReader
End Function
Sub Page_Load(sender As Object, e As EventArgs)
Listbox1.datasource = GetName()
Listbox1.databind()
End Sub
</script>
<html>
<head>
</head>
<body>
<form runat="server">
<p>
</p>
<p>
<asp:ListBox id="ListBox1" runat="server"
DataTextField="LName" DataValueField="ID"></asp:ListBox>
</p>
<p>
<!-- Insert content here -->
</p>
</form>
</body>
</html>
If I wanted to populate my dropdownListbox with first and last name,
how would I code this?
Thanks,
RABMissouri2007