码迷,mamicode.com
首页 > Windows程序 > 详细

C# Repeater 嵌套

时间:2016-06-20 12:31:27      阅读:269      评论:0      收藏:0      [点我收藏+]

标签:

 <table class="table table-bordered table-fixed">
                    <thead>
                        <tr>
                            <th width="40">
                                <input type="checkbox" id="chkAll" onclick="selectAll()" /></th>
                            <th width="60" class="text-center"><%=Resources.Asset.DictViewRowIndex%></th>
                            <th width="280"><%=Resources.Asset.UserDepartments%></th>
                            <th width="120"><%=Resources.Asset.AssetCategory%></th>
                            <th width="120"><%=Resources.Asset.AssetSubClass%></th>
                            <th width="300"><%=Resources.Asset.AssetsCompany%></th>
                            <th width="120"><%=Resources.Asset.AssetName%></th>
                            <th width="80"><%=Resources.Asset.AssetsState%></th>
                            <th width="100">数量</th>
                            <th width="100">原值</th>
                        </tr>
                    </thead>
                    <tbody>
                        <asp:Repeater ID="rptDept" runat="server" OnItemDataBound="rptDept_ItemDataBound">
                            <ItemTemplate>
                                <tr>
                                    <td>
                                        <input type="checkbox" class="assetId" id=<%#((iWS.Assets.DB.Asset)Container.DataItem).Id%> onclick="SelectSingle();" /></td>
                                    <td class="text-center"><%# Container.ItemIndex + 1 + (this.pagerControl.CurrentPageIndex -1) * this.pagerControl.PageSize%></td>
                                    <td><%#((iWS.Assets.DB.Asset)Container.DataItem).Owner!=null?((iWS.Assets.DB.Asset)Container.DataItem).Owner.Depts:"" %></td>
                                    <td colspan="7" style="padding: 0;">
                                        <table style="border: none; width: 100%;">
                                            <asp:Repeater ID="rptDeptSub" runat="server">
                                                <ItemTemplate>
                                                    <tr>
                                                        <td><%#((iWS.Assets.DB.Asset)Container.DataItem).MainCategory!=null?((iWS.Assets.DB.Asset)Container.DataItem).MainCategory.Name:"" %></td>
                                                        <td><%#((iWS.Assets.DB.Asset)Container.DataItem).SubCategory!=null?((iWS.Assets.DB.Asset)Container.DataItem).SubCategory.Name:"" %></td>
                                                        <td><%#((iWS.Assets.DB.Asset)Container.DataItem).Company%></td>
                                                        <td><%#((iWS.Assets.DB.Asset)Container.DataItem).Name%></td>
                                                        <td><%#((iWS.Assets.DB.Asset)Container.DataItem).State!=null?((iWS.Assets.DB.Asset)Container.DataItem).State.Name:"" %></td>
                                                        <td><%#((iWS.Assets.DB.Asset)Container.DataItem).Number%></td>
                                                        <td><%#((iWS.Assets.DB.Asset)Container.DataItem).Cost%></td>
                                                    </tr>
                                                </ItemTemplate>
                                            </asp:Repeater>
                                        </table>
                                    </td>
                                </tr>
                            </ItemTemplate>
                        </asp:Repeater>
                    </tbody>
                </table>
  protected void rptDept_ItemDataBound(object sender, System.Web.UI.WebControls.RepeaterItemEventArgs e)
        {
            try
            {
                if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
                {
                    Repeater rep = e.Item.FindControl("rptCarryoverMsgSub") as Repeater;//找到repeater对象
                    DataRowView rowv = (DataRowView)e.Item.DataItem;
                    string fina = rowv["FinacialCode"] + "";//获取关联的流程ID
                    string proj = rowv["ProjName"] + "";//获取关联的流程ID
                    string yewu = rowv["YeWuSuo"] + "";//获取关联的流程ID

                    var query = from r in carryoverDt.AsEnumerable()
                                where r.Field<string>("FinacialCode").Equals(fina) && r.Field<string>("ProjName").Equals(proj) && r.Field<string>("YeWuSuo").Equals(yewu)
                                select new
                                {
                                    CarryoverName = r.Field<string>("CarryoverName"),
                                    Account = r.Field<decimal>("Account"),
                                    SubDebt = r.Field<decimal>("SubDebt"),
                                    TotalInCome = r.Field<decimal>("TotalInCome"),
                                    HistoryInCome = r.Field<decimal>("HistoryInCome"),
                                    CurrentInCome = r.Field<decimal>("CurrentInCome"),
                                    LastCarryoverToCurrentInCome = r.Field<decimal>("LastCarryoverToCurrentInCome"),
                                    TotalCarryover = r.Field<decimal>("TotalCarryover"),
                                    HistoryCarryover = r.Field<decimal>("HistoryCarryover"),
                                    CurrentCarryover = r.Field<decimal>("CurrentCarryover"),
                                    CurrentFinalBalance = r.Field<decimal>("CurrentFinalBalance"),
                                    CurrentOutCome = r.Field<decimal>("CurrentOutCome"),
                                    OutComeCanCarryover = r.Field<decimal>("OutComeCanCarryover"),
                                    Progess = r.Field<int>("Progess"),
                                    ProgressCanCarryover = r.Field<decimal>("ProgressCanCarryover"),
                                    ThisCarryover = r.Field<decimal>("ThisCarryover")
                                };
                    DataTable dt = DataTableHelper.ToDataTable(query.ToList());
                    rep.DataSource = dt;
                    rep.DataBind();
                }
            }
            catch (Exception ex)
            {
                DiskLog.LogError("ImplementAsyncData-rptAchiveData_ItemDataBound", ex);
            }
        }

 

C# Repeater 嵌套

标签:

原文地址:http://www.cnblogs.com/lishidefengchen/p/5599984.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!