CHAPTER 9 ■ DATA BINDING
378
For example, you could split the earlier example into two pages. In the first page, define a list control
that shows all the available cities:
<asp:SqlDataSource ID="sourceEmployeeCities" runat="server"
ProviderName="System.Data.SqlClient"
ConnectionString="<%$ ConnectionStrings:Northwind %>"
SelectCommand="SELECT DISTINCT City FROM Employees">
</asp:SqlDataSource>
<asp:ListBox ID="lstCities" runat="server" DataSourceID="sourceEmployeeCities"
DataTextField="City"></asp:ListBox><br />
Now, you’ll need a little extra code to copy the selected city to the query string and redirect the page.
Here’s a button that does just that:
protected void cmdGo_Click(object sender, EventArgs e)
{
Response.Redirect("QueryParameter2.aspx?city=" ...