http://dotnet.aspx.cc/ShowDetail.aspx?id=149E5DD7-3B32-461e-ACC6-51D1652E6746

解决方案 »

  1.   

    你的這種應該是SQL語句的問題了
      

  2.   


    这一个是你想要的:<%@ Page Language="C#" %>
    <%@ Import Namespace="System.Data" %>
    <%@ Import Namespace="System.Data.SqlClient" %><script runat=server>void Page_Load(Object sender , EventArgs e) 
    {
    DataSet dstNorthwind;
    SqlConnection conNorthwind;
    SqlDataAdapter dadNorthwind; // Grab the Categories and Products table
    dstNorthwind = new DataSet();
    conNorthwind = new SqlConnection( @"Server=localhost;Integrated Security=SSPI;Database=Northwind" );
    dadNorthwind = new SqlDataAdapter( "Select * From Categories", conNorthwind );
    conNorthwind.Open();
    dadNorthwind.Fill( dstNorthwind, "Categories" );
    dadNorthwind.SelectCommand = new SqlCommand( "Select * From Products", conNorthwind );
    dadNorthwind.Fill( dstNorthwind, "Products" );
    conNorthwind.Close(); // Add Parent/Child Relationship
    dstNorthwind.Relations.Add( "Categories_Products", dstNorthwind.Tables["Categories"].Columns["CategoryID"], dstNorthwind.Tables["Products"].Columns["CategoryID"] ); // Display each Category and Child Products
    foreach (DataRow drowParent in dstNorthwind.Tables["Categories"].Rows)
    {
    lblOutput.Text = "<h3>" + drowParent["CategoryName"] + "</h3>";
    foreach (DataRow drowChild in drowParent.GetChildRows( "Categories_Products" ))
    {
    lblOutput.Text = "<li>" + drowChild["ProductName"];
    }  
    }
    }
    </Script><html>
    <head><title>DataRelation.aspx</title></head>
    <body><asp:Label
      ID="lblOutput"
      Runat="Server" /></body>
    </html>
      

  3.   

    datarelation 是处理datatable之间的关系
      

  4.   

    http://www.denisbauer.com/ASPNETControls/HierarGrid.aspx
    闭馆说的是另一策,hdhai说的不对
      

  5.   

    好像很麻烦,不如多用几个DataGrid.