时间:2021-07-01 10:21:17 帮助过:26人阅读
- <br><%@ Page Language="C#" AutoEventWireup="true" CodeFile="DropLvw.aspx.cs" Inherits="DropLvw" %> <br><br><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <br><br><html xmlns="http://www.w3.org/1999/xhtml"> <br><head runat="server"> <br><title>无标题页</title> <br></head> <br><body> <br><form id="form1" runat="server"> <br><div> <br>请选择大分类:<asp:DropDownList ID="drop" runat="server" AutoPostBack="True" <br>DataSourceID="SqlDataSource1" DataTextField="CategoryName" <br>DataValueField="CategoryID"> <br></asp:DropDownList> <br><asp:SqlDataSource ID="SqlDataSource1" runat="server" <br>ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>" <br>SelectCommand="SELECT [CategoryID], [CategoryName] FROM [Categories]"> <br></asp:SqlDataSource> <br><hr /> <br>该分类下的产品:<br /> <br><asp:ListView ID="lvw" runat="server" DataKeyNames="ProductID" <br>DataSourceID="SqlDataSource2"> <br><ItemTemplate> <br><tr style=""> <br><td> <br><asp:Label ID="ProductIDLabel" runat="server" Text='<%# Eval("ProductID") %>' /> <br></td> <br><td> <br><asp:Label ID="ProductNameLabel" runat="server" <br>Text='<%# Eval("ProductName") %>' /> <br></td> <br><td> <br><asp:Label ID="CategoryIDLabel" runat="server" <br>Text='<%# Eval("CategoryID") %>' /> <br></td> <br><td> <br><asp:Label ID="UnitPriceLabel" runat="server" Text='<%# Eval("UnitPrice") %>' /> <br></td> <br></tr> <br></ItemTemplate> <br><AlternatingItemTemplate> <br><tr style=""> <br><td> <br><asp:Label ID="ProductIDLabel" runat="server" Text='<%# Eval("ProductID") %>' /> <br></td> <br><td> <br><asp:Label ID="ProductNameLabel" runat="server" <br>Text='<%# Eval("ProductName") %>' /> <br></td> <br><td> <br><asp:Label ID="CategoryIDLabel" runat="server" <br>Text='<%# Eval("CategoryID") %>' /> <br></td> <br><td> <br><asp:Label ID="UnitPriceLabel" runat="server" Text='<%# Eval("UnitPrice") %>' /> <br></td> <br></tr> <br></AlternatingItemTemplate> <br><EmptyDataTemplate> <br><table runat="server" style=""> <br><tr> <br><td> <br>未返回数据。</td> <br></tr> <br></table> <br></EmptyDataTemplate> <br><InsertItemTemplate> <br><tr style=""> <br><td> <br><asp:Button ID="InsertButton" runat="server" CommandName="Insert" Text="插入" /> <br><asp:Button ID="CancelButton" runat="server" CommandName="Cancel" Text="清除" /> <br></td> <br><td> <br> </td> <br><td> <br><asp:TextBox ID="ProductNameTextBox" runat="server" <br>Text='<%# Bind("ProductName") %>' /> <br></td> <br><td> <br><asp:TextBox ID="CategoryIDTextBox" runat="server" <br>Text='<%# Bind("CategoryID") %>' /> <br></td> <br><td> <br><asp:TextBox ID="UnitPriceTextBox" runat="server" <br>Text='<%# Bind("UnitPrice") %>' /> <br></td> <br></tr> <br></InsertItemTemplate> <br><LayoutTemplate> <br><table runat="server"> <br><tr runat="server"> <br><td runat="server"> <br><table ID="itemPlaceholderContainer" runat="server" border="0" style=""> <br><tr runat="server" style=""> <br><th runat="server"> <br>ProductID</th> <br><th runat="server"> <br>ProductName</th> <br><th runat="server"> <br>CategoryID</th> <br><th runat="server"> <br>UnitPrice</th> <br></tr> <br><tr ID="itemPlaceholder" runat="server"> <br></tr> <br></table> <br></td> <br></tr> <br><tr runat="server"> <br><td runat="server" style=""> <br></td> <br></tr> <br></table> <br></LayoutTemplate> <br><EditItemTemplate> <br><tr style=""> <br><td> <br><asp:Button ID="UpdateButton" runat="server" CommandName="Update" Text="更新" /> <br><asp:Button ID="CancelButton" runat="server" CommandName="Cancel" Text="取消" /> <br></td> <br><td> <br><asp:Label ID="ProductIDLabel1" runat="server" <br>Text='<%# Eval("ProductID") %>' /> <br></td> <br><td> <br><asp:TextBox ID="ProductNameTextBox" runat="server" <br>Text='<%# Bind("ProductName") %>' /> <br></td> <br><td> <br><asp:TextBox ID="CategoryIDTextBox" runat="server" <br>Text='<%# Bind("CategoryID") %>' /> <br></td> <br><td> <br><asp:TextBox ID="UnitPriceTextBox" runat="server" <br>Text='<%# Bind("UnitPrice") %>' /> <br></td> <br></tr> <br></EditItemTemplate> <br><SelectedItemTemplate> <br><tr style=""> <br><td> <br><asp:Label ID="ProductIDLabel" runat="server" Text='<%# Eval("ProductID") %>' /> <br></td> <br><td> <br><asp:Label ID="ProductNameLabel" runat="server" <br>Text='<%# Eval("ProductName") %>' /> <br></td> <br><td> <br><asp:Label ID="CategoryIDLabel" runat="server" <br>Text='<%# Eval("CategoryID") %>' /> <br></td> <br><td> <br><asp:Label ID="UnitPriceLabel" runat="server" Text='<%# Eval("UnitPrice") %>' /> <br></td> <br></tr> <br></SelectedItemTemplate> <br></asp:ListView> <br><asp:SqlDataSource ID="SqlDataSource2" runat="server" <br>ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>" <br>SelectCommand="SELECT [ProductID], [ProductName], [CategoryID], [UnitPrice] FROM [Products] WHERE ([CategoryID] = @CategoryID)"> <br><SelectParameters> <br><asp:ControlParameter ControlID="drop" DefaultValue="1" Name="CategoryID" <br>PropertyName="SelectedValue" Type="Int32" /> <br></SelectParameters> <br></asp:SqlDataSource> <br></div> <br></form> <br></body> <br></html> <br> <br>/web.config <br><span><u></u></span> 代码如下:<pre class="brush:php;toolbar:false layui-box layui-code-view layui-code-notepad"><ol class="layui-code-ol"><li><br><connectionStrings> <br><add name="NorthwindConnectionString" connectionString="Data <br>Source=.;Initial Catalog=Northwind;Integrated Security=True" <br>providerName="System.Data.SqlClient"/> <br></connectionStrings> <br> <br><strong>1.C,资源下载</strong></li><li> </li><li> </li></ol></pre>