<!-- start parent repeater --> 
<asp:repeater id="rptList" Runat="server">
<ItemTemplate>
<tr align="center" class="listtitle">
<td class="listcellTitle" style="WIDTH: 216px">
<div align="left">
<img src="../images/menu_open.gif" border="0" id="img<%# DataBinder.Eval(Container.DataItem,"lbbh")%>" style="CURSOR:hand" WIDTH="16"
HEIGHT="16" onclick="vbscript:bb('BZ<%# DataBinder.Eval(Container.DataItem,"lbbh")%>')" alt="展开查看明细">
<%# DataBinder.Eval(Container.DataItem,"lbmc")%>
</div>
</td>
<td class="listcellTitle" colspan="6" width="420"><nobr>
<div id="tjmx1" align="left">

</div>
</nobr>
</td>
</tr>
<tbody id="BZ<%# DataBinder.Eval(Container.DataItem,"lbbh")%>">
<tr class="listrow1">
<td class="listcellrow" align="center" style="WIDTH: 216px">用品名称</td>
<td class="listcellrow" width="70" align="center">总采购数</td>
<td class="listcellrow" width="70" align="center">总采购金额</td>
<td class="listcellrow" width="70" align="center">总申请数</td>
<td class="listcellrow" width="70" align="center">总领用数</td>
<td class="listcellrow" width="70" align="center">总领用金额</td>
<td class="listcellrow" width="70" align="center">库存</td>
</tr>
<!-- start child repeater --> 
<asp:repeater id="childList" DataSource="<%#((DataRowView)Container.DataItem).Row.GetChildRows("myRelation")%>" runat="server"> 
  <itemtemplate>
<tr class="listrow2">
<td class="listcellrow" style="WIDTH: 216px">&nbsp;<a href="javascript:popdialog('bgyp_gl_bj.asp?ypbh=1','500px','220px');"><%# DataBinder.Eval(Container.DataItem,"lbbh")%></a></td>
<td class="listcellrow">&nbsp;<%# DataBinder.Eval(Container.DataItem, "[\"ypmc\"]")%><BR></td>
<td class="listcellrow">&nbsp;136.96</td>
<td class="listcellrow">&nbsp;0</td>
<td class="listcellrow">&nbsp;0</td>
<td class="listcellrow">&nbsp;.00</td>
<td class="listcellrow"></td>
</tr>
</ItemTemplate>
</asp:Repeater>
<!-- end child repeater --> 
</tbody>
</ItemTemplate>
</asp:repeater>
<!-- end parent repeater -->

解决方案 »

  1.   

    <!-- start child repeater --> 在这个中间的<%# DataBinder.Eval(Container.DataItem, "[\"ypmc\"]")%>执行后会报错
    ypmc在string strSql2 = "Select * from oa_bgypkc";中是存在的
    可是提示是ypmc 既不是表 yplb 的 DataColumn 也不是 DataRelation。 
    说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: System.ArgumentException: ypmc 既不是表 yplb 的 DataColumn 也不是 DataRelation。源错误: 
    行 587: <tr class="listrow2">
    行 588: <td class="listcellrow" style="WIDTH: 216px">&nbsp;<a href="javascript:popdialog('bgyp_gl_bj.asp?ypbh=1','500px','220px');"><%# DataBinder.Eval(Container.DataItem,"lbbh")%></a></td>
    行 589: <td class="listcellrow">&nbsp;<%# DataBinder.Eval(Container.DataItem, "[\"ypmc\"]")%><BR></td>
    行 590: <td class="listcellrow">&nbsp;136.96</td>
    行 591: <td class="listcellrow">&nbsp;0</td>
     <!-- end child repeater --> 
      

  2.   

    I don't have your database, so I cannot test it for you, can you play with the example in 
    http://support.microsoft.com/default.aspx?scid=306154and add your code to it, it should be very simiar with you are doing
      

  3.   

    it should be very similar to what you are doing
      

  4.   

    OK,那个例子我看过了,我就是照着做的数据结构给你看看。我的问题就在<%# DataBinder.Eval(Container.DataItem, "[\"ypmc\"]")%>上为什么我只能取得父表的值,不能取到子表的值。对了我的子表是有两个主键~!!!!
      

  5.   

    >>>>对了我的子表是有两个主键then that is probably the problem, can you try the following and see what you get?<!-- start child repeater --> 
    <asp:repeater id="childList" DataSource="<%#((DataRowView)Container.DataItem).Row.GetChildRows("myRelation")%>" runat="server"> 
               <ItemTemplate>
                    <%# Container.DataItem %>
                </ItemTemplate>
    </asp:Repeater>
    <!-- end child repeater --> 
      

  6.   

    我表结构改了一下!!现在两个表分别为
    if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[OA_BGYPLB]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
    drop table [dbo].[OA_BGYPLB]
    GOCREATE TABLE [dbo].[OA_BGYPLB] (
    [LBBH] [int] IDENTITY (1, 1) NOT NULL ,
    [LBMC] [nvarchar] (60) COLLATE Chinese_PRC_CI_AS NULL 
    ) ON [PRIMARY]
    GO
    if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[OA_BGYPKC]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
    drop table [dbo].[OA_BGYPKC]
    GOCREATE TABLE [dbo].[OA_BGYPKC] (
    [YPBH] [int] NOT NULL ,
    [YPMC] [nvarchar] (60) COLLATE Chinese_PRC_CI_AS NULL ,
    [LBBH] [int] NOT NULL ,
    [GG] [nvarchar] (20) COLLATE Chinese_PRC_CI_AS NULL ,
    [DW] [nvarchar] (20) COLLATE Chinese_PRC_CI_AS NULL ,
    [PJJJ] [decimal](14, 2) NULL ,
    [RKSL] [decimal](14, 4) NULL ,
    [CKSL] [decimal](14, 4) NULL ,
    [GXSJ] [nvarchar] (20) COLLATE Chinese_PRC_CI_AS NULL ,
    [KCBJ] [decimal](14, 4) NULL 
    ) ON [PRIMARY]
    GO这么用的结果是<!-- start child repeater --> 
    <asp:repeater id="childList" DataSource="<%#((DataRowView)Container.DataItem).Row.GetChildRows("myRelation")%>" runat="server"> 
               <ItemTemplate>
                    <%# Container.DataItem %>
                </ItemTemplate>
    </asp:Repeater>
    <!-- end child repeater --> 
    结果是:System.Data.DataRowView
      

  7.   

    <!-- start child repeater --> 
    <asp:repeater id="childList" DataSource="<%#((DataRowView)Container.DataItem).Row.GetChildRows("myRelation")%>" runat="server"
     OnItemDataBound="Repeater1_RepeaterItemEventHandler"

               <ItemTemplate>
                    <%# Container.DataItem %>
                </ItemTemplate>
    </asp:Repeater>
    <!-- end child repeater --> 
    ....void Repeater1_RepeaterItemEventHandler(object sender,   RepeaterItemEventArgs e)
    {    DataRow dr= (DataRow)e.Item.DataItem;
        DataTable dt = dr.Table;
        foreach (DataColumn dc in dt.Columns)
          Response.Write(String.Format("****{0}:{1}****",dc.ColumnName, dr[dc]));}
      

  8.   

    怎么不执行void Repeater1_RepeaterItemEventHandler(object sender,   RepeaterItemEventArgs e)
    {    DataRow dr= (DataRow)e.Item.DataItem;
        DataTable dt = dr.Table;
        foreach (DataColumn dc in dt.Columns)
          Response.Write(String.Format("****{0}:{1}****",dc.ColumnName, dr[dc]));}
    内的内容啊?
      

  9.   

    the code should be in your cs file and you might want to add protected or public before it, also do you have this:OnItemDataBound="Repeater1_RepeaterItemEventHandler"
      

  10.   

    是不是要初始化OnItemDataBound啊,我现在进不了web视图!!
      

  11.   

    思归好了,谢谢!!!!!!!!!!!
    劳你操心了!!!我新建了一个文件,在这个文件做嵌套没问题后再放到我的目的文件里!!具体的哪里出的问题还是不明白。我觉得微软的东西真得有时间说智能很智能可说傻也很傻!!hehe