<%@ Page language="c#" Codebehind="DataGridMasterFrom.aspx.cs" AutoEventWireup="false" Inherits="CommonFunction.DataGridMasterFrom" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
	<HEAD>
		<title>DataGridMasterFrom</title>
		<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
		<meta name="CODE_LANGUAGE" Content="C#">
		<meta name="vs_defaultClientScript" content="JavaScript">
		<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
	</HEAD>
	<body MS_POSITIONING="GridLayout">
		<form id="Form1" method="post" runat="server">
			<h2>使用DataGrid控件实现以主细表显示数据</h2>
			<asp:DataGrid id="dgMaster" style="Z-INDEX: 101; LEFT: 48px; POSITION: absolute; TOP: 64px" runat="server"
				AutoGenerateColumns="False" ShowHeader="False" Width="368px">
				<Columns>
					<asp:TemplateColumn>
						<ItemTemplate>
							<TABLE cellSpacing="0" cellPadding="0" width="100%" border="0">
								<TR>
									<TD bgColor="#3399ff"><FONT color="#ffffff"><B>订单号：
												<%# DataBinder.Eval(Container.DataItem, "OrderID") %>
											</B></FONT>
									</TD>
								</TR>
								<TR>
									<TD align="right">
										<asp:DataGrid id=dgDetail runat="server" AutoGenerateColumns="False" DataSource='<%# ((System.Data.DataRowView)Container.DataItem).CreateChildView("tableRelation") %>' DataKeyField="OrderID" BorderColor="#336666" BorderStyle="Double" BorderWidth="3px" BackColor="White" CellPadding="4" GridLines="Horizontal" Width="100%" Font-Size="Smaller">
											<SelectedItemStyle Font-Bold="True" ForeColor="White" BackColor="#339966"></SelectedItemStyle>
											<ItemStyle ForeColor="#333333" BackColor="White"></ItemStyle>
											<HeaderStyle Font-Bold="True" ForeColor="White" BackColor="#336666"></HeaderStyle>
											<FooterStyle ForeColor="#333333" BackColor="White"></FooterStyle>
											<Columns>
												<asp:BoundColumn Visible="False" DataField="OrderID" ReadOnly="True"></asp:BoundColumn>
												<asp:TemplateColumn HeaderText="产品名称">
													<HeaderStyle Width="250px"></HeaderStyle>
													<ItemTemplate>
														<%# DataBinder.Eval(Container.DataItem, "ProductName") %>
													</ItemTemplate>
												</asp:TemplateColumn>
												<asp:BoundColumn DataField="UnitPrice" HeaderText="单价" DataFormatString="{0:c}"></asp:BoundColumn>
												<asp:BoundColumn DataField="Quantity" HeaderText="数量"></asp:BoundColumn>
												<asp:BoundColumn DataField="Discount" HeaderText="折扣"></asp:BoundColumn>
											</Columns>
											<PagerStyle HorizontalAlign="Center" ForeColor="White" BackColor="#336666" Mode="NumericPages"></PagerStyle>
										</asp:DataGrid></TD>
								</TR>
							</TABLE>
						</ItemTemplate>
					</asp:TemplateColumn>
				</Columns>
			</asp:DataGrid>
		</form>
	</body>
</HTML>
