|
mar0364 -> RE: Expression (Drop-Down List) (2/2/2007 17:47:45)
|
The following code does what your takling about all on the same page. Take a look at the code it may help you solve your problem. If you have the pubs database running on you server you should be able to run the code.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ Page Language="VB" %>
<html dir="ltr" xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled 1</title>
</head>
<body>
<form id="form1" runat="server">
<asp:DropDownList runat="server" id="DropDownList1" AutoPostBack="True">
<asp:ListItem>CA</asp:ListItem>
<asp:ListItem>UT</asp:ListItem>
<asp:ListItem>IN</asp:ListItem>
</asp:DropDownList>
<br />
<asp:GridView runat="server" id="GridView1" AutoGenerateColumns="False" DataSourceID="SqlDataSource1" DataKeyNames="au_id">
<Columns>
<asp:boundfield ReadOnly="True" DataField="au_id" SortExpression="au_id" HeaderText="au_id">
</asp:boundfield>
<asp:boundfield DataField="au_lname" SortExpression="au_lname" HeaderText="au_lname">
</asp:boundfield>
<asp:boundfield DataField="au_fname" SortExpression="au_fname" HeaderText="au_fname">
</asp:boundfield>
<asp:boundfield DataField="city" SortExpression="city" HeaderText="city">
</asp:boundfield>
<asp:boundfield DataField="state" SortExpression="state" HeaderText="state">
</asp:boundfield>
</Columns>
</asp:GridView>
<asp:SqlDataSource runat="server" ID="SqlDataSource1" ConnectionString="<%$ ConnectionStrings:Pubs %>" SelectCommand="SELECT [au_id], [au_lname], [au_fname], [city], [state] FROM [authors] WHERE ([state] = @state)">
<SelectParameters>
<asp:controlparameter PropertyName="SelectedValue" Type="String" DefaultValue="ca" Name="state" ControlID="DropDownList1" />
</SelectParameters>
</asp:SqlDataSource>
</form>
</body>
</html>
|
|
|
|