<form id="form1" runat="server">
<div style="text-align: center">
<asp:Repeater ID="Repeater1" runat="server">
<HeaderTemplate>
<table class="tablesorter" cellspacing="1" style="word-break:break-all;table-layout:fixed;">
<thead>
<tr>
<th style="width:100px;">品名</th>
<th style="width:70px;">照片</th>
<th style="width:80px;">订货时间</th>
<th style="width:80px;">颜色</th>
<th style="width:50px;">数量</th>
<th style="width:60px;">单价</th>
<th style="width:60px;">总价</th>
<th style="width:100px;">备注</th>
<th style="width:80px;">客户</th>
</tr>
</thead>
</HeaderTemplate>
<ItemTemplate>
<tbody>
<tr>
<td><a href="editOrder.aspx?id=<%#Eval("id")%>" target="_blank"><%#Eval("productName")%></a></td>
<td><%#showPhoto(Eval("photoName").ToString(), Eval("productName").ToString())%></td>
<td><%#Eval("orderDate", "{0:d}")%><br /><font color="#FF0000"><%#Eval("outDate", "{0:d}")%></font><br />剩 <%#Eval("restDay")%>天</td>
<td><%#Eval("smallType")%><%#showOtherColor(Eval("otherColor").ToString())%></td>
<td><%#Eval("pcs")%></td>
<td><%#Eval("price")%></td>
<td><%#Eval("total")%><%#showReduce(Eval("reduce").ToString())%></td>
<td><%#Eval("re")%></td>
<td><%#Eval("clientName")%></td>
</tr>
</tbody> <asp:Repeater id="Repeater2" runat="server" DataSource='<%#Eval("myRel")%>'>
<ItemTemplate>
<tr><td><%#Eval("clientId")%></td><td align="right"></td></tr>
</ItemTemplate>
</asp:Repeater>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
</div>
</form>SqlConnection conn = new SqlConnection(conString);
DataSet ds = new DataSet();
SqlDataAdapter da1 = new SqlDataAdapter("select FactoryOrder.id,orderDate,outDate,(DATEDIFF(day,getdate(),outDate))restDay,productName,price,pcs,reduce,total,otherColor,FactoryOrder.re,cutting,carpenter,polish,painting,ithas,photoName,clientName,smallType,FactoryOrder.clientId from FactoryOrder left join Client on Client.clientId=FactoryOrder.clientId left join TypeList on TypeList.SB=color where FactoryOrder.id in (21,22) order by FactoryOrder.clientId asc", conn);
SqlDataAdapter da2 = new SqlDataAdapter("select * from Client where clientId in (select clientId from FactoryOrder where id in (22,21))", conn);
SqlDataAdapter da3 = new SqlDataAdapter("select clientId from FactoryOrder where id in (22,21) group by clientId ", conn);
da1.Fill(ds, "order");
da2.Fill(ds, "Client");
da3.Fill(ds, "ClientId"); ds.Relations.Add("myRel", ds.Tables["ClientId"].Columns["clientId"], ds.Tables["order"].Columns["clientId"]);
//这里的第一个参数是添加的联系的名称,第二个参数是该关系的父列,第三个参数是该关系的子列。
this.Repeater1.DataSource = ds.Tables["order"];
this.Repeater1.DataBind();
DataBinding:“System.Data.DataRowView”不包含名为“myRel”的属性这个是为什么?
你确定你的ORDER 中有clientId?你看看你的SQL语句啊。select FactoryOrder.id,orderDate,outDate,(DATEDIFF(day,getdate(),outDate))restDay,productName,price,pcs,reduce,total,otherColor,FactoryOrder.re,cutting,carpenter,polish,painting,ithas,photoName,clientName,smallType,FactoryOrder.clientId from FactoryOrder left join Client on Client.clientId=FactoryOrder.clientId left join TypeList on TypeList.SB=color where FactoryOrder.id in (21,22) order by FactoryOrder.clientId asc
FactoryOrder.clientId as clientId 这样试下。还有个问题要注意 你的表名 跟字段名字要有区别 只有个大小写 不好的。。
datasource='<%# ((DataRowView)Container.DataItem).Row.GetChildRows("myrelation") %>'>