string strSql = "select * from Article_Class where A_Type='3' order by Classid;select top 5  * from [Article]";
SqlDataAdapter da=new SqlDataAdapter(strSql,conn);
DataSet ds=new DataSet();
da.Fill(ds);ds.Tables[0].TableName = "Article_Class" ;
ds.Tables[1].TableName = "Article" ;
DataColumn Parent = ds.Tables["Article_Class"].Columns["Classid"];
DataColumn Child = ds.Tables["Article"].Columns["Classid"];
DataRelation FlashRelation  = new DataRelation("FlashRelation", Parent, Child,false);
ds.Relations.Add(FlashRelation) ;
DL1.DataSource=ds.Tables["Article_Class"].DefaultView;
DL1.DataBind();
为什么不能显示我需要的结果就是
就是每个对应的分类下显示5条数据如果select top 5  * from [Article] 改成select   * from [Article]
能全部显示

解决方案 »

  1.   

    http://blog.csdn.net/wj2929/archive/2005/02/13/286932.aspx
      

  2.   

    是Datalist 不是Repeater啊
      

  3.   

    是Datalist 不是Repeater啊
    -----------------------------
    这并没有什么区别,其实就是动态指定嵌套控件的数据源而已,可以参考www.asp.net上的报表入门套件
      

  4.   

    http://community.csdn.net/Expert/topic/3296/3296579.xml?temp=.673794
    倒,问题一样的也没有解决 <asp:DataList id="DL1" runat="server" EditItemStyle-BackColor="yellow" AlternatingItemStyle-BackColor="Gainsboro"
    HeaderStyle-BackColor="#aaaadd" Width="600px" Height="732px" RepeatColumns="2" RepeatDirection="Horizontal">
    <EditItemStyle BackColor="Yellow"></EditItemStyle>
    <AlternatingItemStyle BackColor="White"></AlternatingItemStyle>
    <ItemTemplate>
    <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111"
    width="302" id="AutoNumber1" height="241">
    <tr>
    <td width="344" height="29"><b><%# DataBinder.Eval(Container.DataItem, "Name") %></b></td>
    </tr>
    <tr>
    <td width="344" height="193">
    <div align="center">
    <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111"
    width="95%" id="AutoNumber2" height="95%">
    <tr>
    <td width="100%">
    <asp:DataList id="DL2" runat="server" DataSource='<%# ((DataRowView)Container.DataItem).CreateChildView("FlashRelation") %>'>
    <AlternatingItemStyle BackColor="#EFEFEF"></AlternatingItemStyle>
    <ItemTemplate>
    <table width="100%" border="0" cellpadding="0" cellspacing="1">
    <tr>
    <td width="240">
    <A href='list.aspx?id=<%# DataBinder.Eval(Container.DataItem, "ID") %>'>
    <%# DataBinder.Eval(Container.DataItem, "A_Title") %>
    </A>
    </td>
    </tr>
    </table>
    </ItemTemplate>
    </asp:DataList>
    </td>
    </tr>
    </table>
    </div>
    </td>
    </tr>
    <tr>
    <td width="344" height="26">更多</td>
    </tr>
    </table>
    </ItemTemplate>
    <HeaderStyle BackColor="White"></HeaderStyle>
    </asp:DataList>