📄 nestedrowfilter.aspx
字号:
<%@ Page Language="C#" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<script runat=server>
DataSet dstNorthwind;
DataView dvwProducts;
void Page_Load(Object sender , EventArgs e)
{
SqlConnection conNorthwind;
SqlDataAdapter dadNorthwind;
dstNorthwind = new DataSet();
conNorthwind = new SqlConnection( @"Server=localhost;Integrated Security=SSPI;Database=Northwind" );
dadNorthwind = new SqlDataAdapter( "Select * From Categories", conNorthwind );
dadNorthwind.Fill( dstNorthwind, "Categories" );
dadNorthwind.SelectCommand = new SqlCommand( "Select * From Products", conNorthwind );
dadNorthwind.Fill( dstNorthwind, "Products" );
dvwProducts = dstNorthwind.Tables[ "Products" ].DefaultView;
rptCategories.DataSource = dstNorthwind;
rptCategories.DataMember = "Categories";
rptCategories.DataBind();
}
DataView FilterProducts( int intCatID )
{
dvwProducts.RowFilter = "CategoryID=" + intCatID;
return dvwProducts;
}
</Script>
<html>
<head><title>NestedRowFilter.aspx</title></head>
<body>
<asp:Repeater
ID="rptCategories"
Runat="Server">
<ItemTemplate>
<h2><%#DataBinder.Eval(Container.DataItem, "CategoryName" )%></h2>
<asp:DataGrid
DataSource='<%#FilterProducts(1) %>'
Runat="Server" />
</ItemTemplate>
</asp:Repeater>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -