stevenyoo321
New member
- Local time
- Yesterday, 17:10
- Joined
- Feb 2, 2007
- Messages
- 6
Greetings I'm currently trying to determine how to make a combo box which is connected to the data I queried using SqL Command object. I want to learn how to make a combo box in which the user will be able to choose either "true" or "false" in doing so it will show they desire. Currently I was able to make a textbox in which the user must enter "true" or "false to get the info they desired. But I just want to have a combobox to make it easier for the user. So if anyone can help out I'd greatly appreciate it.
<%@ Page Language="VB" Debug="true" %>
<%@ Import namespace="System.Data" %>
<%@ Import namespace="System.Data.Sqlclient" %>
<script runat="server">
Sub Page_Load(Sender As Object, E As EventArgs)
If Page.IsPostback Then
Dim strConnection As String = "server=TESLA\SQLEXPRESS;database=Northwind;UID=is310;Password=mis310;"
Dim objConnection As New SqlConnection(strConnection)
Dim strContacted As String = txtContacted.Text
Dim strSQL As String = "SELECT CompanyName, ContactName, Address, Contacted from Customers where Contacted= '" + strContacted + "'"
Dim objCommand As New SqlCommand(strSQL, objConnection)
objConnection.Open()
DataGrid1.DataSource = objCommand.ExecuteReader()
DataGrid1.DataBind()
objConnection.Close()
End If
End Sub
</script>
<html>
<head>
</head>
<body>
<asp: DataGrid id="DataGrid1" runat="server"
Backcolor="lightgray"
ForeColor="darkblue"
HeaderStyle-backcolor="silver"
BorderColor="Black" />
<P>
<form runat="server">
Please enter Contacted:
<asp:textbox id="txtContacted" runat="server"></asp:textbox><br>
<input type="reset" value="Clear form" /><br>
<input type="submit" value="Submit Query" />
</form>
</body>
</html>
<%@ Page Language="VB" Debug="true" %>
<%@ Import namespace="System.Data" %>
<%@ Import namespace="System.Data.Sqlclient" %>
<script runat="server">
Sub Page_Load(Sender As Object, E As EventArgs)
If Page.IsPostback Then
Dim strConnection As String = "server=TESLA\SQLEXPRESS;database=Northwind;UID=is310;Password=mis310;"
Dim objConnection As New SqlConnection(strConnection)
Dim strContacted As String = txtContacted.Text
Dim strSQL As String = "SELECT CompanyName, ContactName, Address, Contacted from Customers where Contacted= '" + strContacted + "'"
Dim objCommand As New SqlCommand(strSQL, objConnection)
objConnection.Open()
DataGrid1.DataSource = objCommand.ExecuteReader()
DataGrid1.DataBind()
objConnection.Close()
End If
End Sub
</script>
<html>
<head>
</head>
<body>
<asp: DataGrid id="DataGrid1" runat="server"
Backcolor="lightgray"
ForeColor="darkblue"
HeaderStyle-backcolor="silver"
BorderColor="Black" />
<P>
<form runat="server">
Please enter Contacted:
<asp:textbox id="txtContacted" runat="server"></asp:textbox><br>
<input type="reset" value="Clear form" /><br>
<input type="submit" value="Submit Query" />
</form>
</body>
</html>