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]
能全部显示
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]
能全部显示
解决方案 »
- 哪位给ps两张图,本人做的太难看了
- 自定义控件得不到值
- 关于URL加密问题
- 求教如何解决WEB项目打包后文件权限丢失的问题?
- 新手问题,数据库连接出错
- asp.net的小问题
- 关于DataGrid显示记录问题,急需各位指点!!在线等待
- Datagird中修改更新刪除記錄問題
- 求VS2012正则表达式替换方法 用正则(?=Enum)[^\s]*?(?=ToString)查找出来的后如何进行替换,谢谢
- 求教一个js的进度条的原码
- 请高手指点!!!为什么这段程序没有用啊?浏览器上什么都没有!
- 求<Applying UML and Patterns : An Introduction to Object-Oriented Analysis and Design and Iterative Development (3rd Edition)>电
-----------------------------
这并没有什么区别,其实就是动态指定嵌套控件的数据源而已,可以参考www.asp.net上的报表入门套件
倒,问题一样的也没有解决 <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>