<%@ Page Language="C#" AutoEventWireup="true" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:SqlDataSource ID="sourceProducts"
runat="server"
ConnectionString="<%$ ConnectionStrings:Northwind %>"
SelectCommand="SELECT * FROM Products"></asp:SqlDataSource>
<asp:DropDownList ID="lstProducts"
runat="server"
AutoPostBack="True"
DataSourceID="sourceProducts"
DataTextField="ProductName"
DataValueField="ProductID"
Width="184px">
</asp:DropDownList>
<br />
<br />
<asp:SqlDataSource ID="sourceProductFull"
runat="server"
ConnectionString="<%$ ConnectionStrings:Northwind %>"
SelectCommand="SELECT * FROM Products WHERE ProductID=@ProductID">
<SelectParameters>
<asp:ControlParameter Name="ProductID"
ControlID="lstProducts"
PropertyName="SelectedValue" />
</SelectParameters>
</asp:SqlDataSource>
<asp:FormView ID="FormView1"
runat="server"
DataSourceID="sourceProductFull"
Width="184px"
CellPadding="5">
<ItemTemplate>
<b>In Stock:</b>
<%# Eval("UnitsInStock") %>
<br />
<b>On Order:</b>
<%# Eval("UnitsOnOrder") %>
<br />
<b>Reorder:</b>
<%# Eval("ReorderLevel") %>
<br />
<br />
</ItemTemplate>
</asp:FormView>
</div>
</form>
</body>
</html>
File: Web.config
<?xml version="1.0"?>
<configuration>
<connectionStrings>
<add name="Northwind" connectionString="Data Source=localhost\SQLEXPRESS;Initial Catalog=Northwind;Integrated Security=SSPI"/>
</connectionStrings>
</configuration>
|