1. A. Run
1. B, source code
Copy codeThe Code is as follows:
<% @ Page Language = "C #" AutoEventWireup = "true" CodeFile = "DropLvw. aspx. cs" Inherits = "DropLvw" %>
<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<Html xmlns = "http://www.w3.org/1999/xhtml">
<Head runat = "server">
<Title> No title page </title>
</Head>
<Body>
<Form id = "form1" runat = "server">
<Div>
Select a category: <asp: DropDownList ID = "drop" runat = "server" AutoPostBack = "True"
DataSourceID = "SqlDataSource1" DataTextField = "CategoryName"
DataValueField = "CategoryID">
</Asp: DropDownList>
<Asp: SqlDataSource ID = "SqlDataSource1" runat = "server"
ConnectionString = "<% $ ConnectionStrings: NorthwindConnectionString %>"
SelectCommand = "SELECT [CategoryID], [CategoryName] FROM [Categories]">
</Asp: SqlDataSource>
<Hr/>
Products under this category: <br/>
<Asp: ListView ID = "lvw" runat = "server" DataKeyNames = "ProductID"
Performanceid = "sqlperformance2">
<ItemTemplate>
<Tr style = "">
<Td>
<Asp: Label ID = "ProductIDLabel" runat = "server" Text = '<% # Eval ("ProductID") %>'/>
</Td>
<Td>
<Asp: Label ID = "ProductNameLabel" runat = "server"
Text = '<% # Eval ("ProductName") %>'/>
</Td>
<Td>
<Asp: Label ID = "CategoryIDLabel" runat = "server"
Text = '<% # Eval ("CategoryID") %>'/>
</Td>
<Td>
<Asp: Label ID = "UnitPriceLabel" runat = "server" Text = '<% # Eval ("UnitPrice") %>'/>
</Td>
</Tr>
</ItemTemplate>
<AlternatingItemTemplate>
<Tr style = "">
<Td>
<Asp: Label ID = "ProductIDLabel" runat = "server" Text = '<% # Eval ("ProductID") %>'/>
</Td>
<Td>
<Asp: Label ID = "ProductNameLabel" runat = "server"
Text = '<% # Eval ("ProductName") %>'/>
</Td>
<Td>
<Asp: Label ID = "CategoryIDLabel" runat = "server"
Text = '<% # Eval ("CategoryID") %>'/>
</Td>
<Td>
<Asp: Label ID = "UnitPriceLabel" runat = "server" Text = '<% # Eval ("UnitPrice") %>'/>
</Td>
</Tr>
</AlternatingItemTemplate>
<EmptyDataTemplate>
<Table runat = "server" style = "">
<Tr>
<Td>
No data is returned. </Td>
</Tr>
</Table>
</EmptyDataTemplate>
<InsertItemTemplate>
<Tr style = "">
<Td>
<Asp: Button ID = "InsertButton" runat = "server" CommandName = "Insert" Text = "Insert"/>
<Asp: Button ID = "CancelButton" runat = "server" CommandName = "Cancel" Text = "clear"/>
</Td>
<Td>
</Td>
<Td>
<Asp: TextBox ID = "ProductNameTextBox" runat = "server"
Text = '<% # Bind ("ProductName") %>'/>
</Td>
<Td>
<Asp: TextBox ID = "CategoryIDTextBox" runat = "server"
Text = '<% # Bind ("CategoryID") %>'/>
</Td>
<Td>
<Asp: TextBox ID = "UnitPriceTextBox" runat = "server"
Text = '<% # Bind ("UnitPrice") %>'/>
</Td>
</Tr>
</InsertItemTemplate>
<LayoutTemplate>
<Table runat = "server">
<Tr runat = "server">
<Td runat = "server">
<Table ID = "itemPlaceholderContainer" runat = "server" border = "0" style = "">
<Tr runat = "server" style = "">
<Th runat = "server">
ProductID </th>
<Th runat = "server">
ProductName </th>
<Th runat = "server">
CategoryID </th>
<Th runat = "server">
UnitPrice </th>
</Tr>
<Tr ID = "itemPlaceholder" runat = "server">
</Tr>
</Table>
</Td>
</Tr>
<Tr runat = "server">
<Td runat = "server" style = "">
</Td>
</Tr>
</Table>
</LayoutTemplate>
<EditItemTemplate>
<Tr style = "">
<Td>
<Asp: Button ID = "UpdateButton" runat = "server" CommandName = "Update" Text = "Update"/>
<Asp: Button ID = "CancelButton" runat = "server" CommandName = "Cancel" Text = "Cancel"/>
</Td>
<Td>
<Asp: Label ID = "ProductIDLabel1" runat = "server"
Text = '<% # Eval ("ProductID") %>'/>
</Td>
<Td>
<Asp: TextBox ID = "ProductNameTextBox" runat = "server"
Text = '<% # Bind ("ProductName") %>'/>
</Td>
<Td>
<Asp: TextBox ID = "CategoryIDTextBox" runat = "server"
Text = '<% # Bind ("CategoryID") %>'/>
</Td>
<Td>
<Asp: TextBox ID = "UnitPriceTextBox" runat = "server"
Text = '<% # Bind ("UnitPrice") %>'/>
</Td>
</Tr>
</EditItemTemplate>
<SelectedItemTemplate>
<Tr style = "">
<Td>
<Asp: Label ID = "ProductIDLabel" runat = "server" Text = '<% # Eval ("ProductID") %>'/>
</Td>
<Td>
<Asp: Label ID = "ProductNameLabel" runat = "server"
Text = '<% # Eval ("ProductName") %>'/>
</Td>
<Td>
<Asp: Label ID = "CategoryIDLabel" runat = "server"
Text = '<% # Eval ("CategoryID") %>'/>
</Td>
<Td>
<Asp: Label ID = "UnitPriceLabel" runat = "server" Text = '<% # Eval ("UnitPrice") %>'/>
</Td>
</Tr>
</SelectedItemTemplate>
</Asp: ListView>
<Asp: SqlDataSource ID = "SqlDataSource2" runat = "server"
ConnectionString = "<% $ ConnectionStrings: NorthwindConnectionString %>"
SelectCommand = "SELECT [ProductID], [ProductName], [CategoryID], [UnitPrice] FROM [Products] WHERE ([CategoryID] = @ CategoryID)">
<SelectParameters>
<Asp: ControlParameter ControlID = "drop" DefaultValue = "1" Name = "CategoryID"
PropertyName = "SelectedValue" Type = "Int32"/>
</SelectParameters>
</Asp: SqlDataSource>
</Div>
</Form>
</Body>
</Html>
/Web. config
Copy codeThe Code is as follows:
<ConnectionStrings>
<Add name = "NorthwindConnectionString" connectionString = "Data
Source =.; Initial Catalog = Northwind; Integrated Security = True"
ProviderName = "System. Data. SqlClient"/>
</ConnectionStrings>
1. C. Download Resources