扫一扫
分享文章到微信
扫一扫
关注官方公众号
至顶头条
作者:builder.com.cn 2007年4月2日
关键字:
<%@ Page Language="C#" %>
<html>
<head id="Head1" runat="server">
<title>Master-Detail Page Example</title>
</head><body>
<form id="frmMasterDetail" runat="server">
<b>Select a city:</b>
<asp:DropDownList ID="DropDownList1" DataSourceID="SqlDataSource2" AutoPostBack="true"
DataTextField="City" runat="server" />
<asp:SqlDataSource ID="SqlDataSource2" runat="server" SelectCommand="SELECT DISTINCT City FROM Employees"
ConnectionString="Server=localhost;Database=Northwind;Trusted_Connection=true" />
<asp:GridView ID="GridView1" AllowSorting="True" AllowPaging="True" runat="server"
DataSourceID="SqlDataSource1" DataKeyNames="EmployeeID"
AutoGenerateColumns="False" Width="427px" PageSize="10" BackColor="#c0c0c0"
BorderColor="black" BorderStyle="Groove" BorderWidth="5" Caption="GridView Example">
<SelectedRowStyleBackColor="yellow" />
<Columns>
<asp:CommandFieldShowSelectButton="True" />
<asp:BoundFieldDataField="EmployeeID" HeaderText="ID" ReadOnly="True" SortExpression="EmployeeID" />
<asp:BoundFieldDataField="LastName" HeaderText="Last" SortExpression="LastName" />
<asp:BoundFieldDataField="FirstName" HeaderText="First" SortExpression="FirstName" />
<asp:BoundFieldDataField="Region" HeaderText="Region" SortExpression="Region" />
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" SelectCommand="SELECT EmployeeID, LastName, FirstName, Region FROM Employees WHERE (City=@City)"
ConnectionString="Server=localhost;Database=Northwind;Trusted_Connection=true">
<SelectParameters>
<asp:ControlParameterControlID="DropDownList1" Name="City" PropertyName="SelectedValue" Type="String" />
</SelectParameters>
</asp:SqlDataSource>
<asp:DetailsViewAutoGenerateRows="False" DataKeyNames="EmployeeID"
DataSourceID="SqlDataSource3"
HeaderText="Employee Details" ID="DetailsView1" runat="server" Width="275px">
<Fields>
<asp:BoundFieldDataField="EmployeeID" HeaderText="ID" ReadOnly="True" />
<asp:BoundFieldDataField="LastName" HeaderText="Last" />
<asp:BoundFieldDataField="FirstName" HeaderText="First" />
<asp:BoundFieldDataField="Region" HeaderText="Region" />
</Fields>
</asp:DetailsView>
<asp:SqlDataSource ConnectionString="Server=localhost;Database=Northwind;Trusted_Connection=true" ID="SqlDataSource3"
runat="server" SelectCommand="SELECT EmployeeID, LastName, FirstName, Region FROM Employees WHERE (EmployeeID = @EmployeeID)">
<SelectParameters>
<asp:ControlParameterControlID="GridView1" Name="EmployeeID" PropertyName="SelectedValue" Type="String" />
</SelectParameters>
</asp:SqlDataSource>
</form></body></html>
如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。
现场直击|2021世界人工智能大会
直击5G创新地带,就在2021MWC上海
5G已至 转型当时——服务提供商如何把握转型的绝佳时机
寻找自己的Flag
华为开发者大会2020(Cloud)- 科技行者