asp.net Table,数据重复 合并

在这后台代码就不些了主要是前提循环

@{
    ViewBag.Title = "QueryDetails";
    Business.BLL.DC_ProductSkillPhysicalBLL bll = new Business.BLL.DC_ProductSkillPhysicalBLL();
    System.Data.DataSet ds = bll.GetListPhysicalFirsts();//取大项
    System.Data.DataTable dt = ds.Tables[0];
}
<style>
    .listtable thead tr th {
        text-align: center;
    }

    .date {
        margin-top: 40px;
    }

    .divs {
        word-wrap: break-word;
        word-break: normal;
    }
</style>
<style>
    .tdTitle {
        text-align: right;
    }

    .querybar table tr td {
        padding-top: 2px;
        padding-bottom: 2px;
    }

        .querybar table tr td input {
             203px;
        }

        .querybar table tr td select {
             208px;
        }
</style>
<link href="~/Scripts/CSS/peixun.css" rel="stylesheet" />

<form method="post" id="searchform" name="searchform" action="/ProductSkillPhysical/Index?@ViewBag.Query" >
    <div>
        <table border="0" class="listtable" style="text-align: center;">
            <thead>
                <tr>
                    <th>盘点大项</th>
                    <th>盘点小项</th>
                    <th>选项</th>
                    <th>填写说明——在系统的某个地方展示</th>
                </tr>
            </thead>
            <tbody>
                @foreach (System.Data.DataRow var in dt.Rows) //循环取大项
                {
                    System.Data.DataRow dr = var;
                    List<Data.Model.DC_ProductSkillPhysical> list = bll.GetListPhysicalSecond(@dr["PhysicalFirsts"].ToString()); //取小项
                    int s = list.Count + 1;

                    var dtTable = new System.Data.DataTable(); 
                    <tr>
                        <td rowspan="@s">@dr["PhysicalFirsts"]</td>
                    </tr>                                         
                    foreach (DC_ProductSkillPhysical item in list) //循环取小项
                    {
                        dtTable = bll.GetListQuery(dr["PhysicalFirsts"].ToString(), item.PhysicalSecond); //取后两项
                        int tss = dtTable.Rows.Count;
                       
                    <tr>
                        <td>
                            @item.PhysicalSecond
                        </td>
                        <td>
                            <table>
                                @foreach (System.Data.DataRow dat in dtTable.Rows)//循环取后两项
                                {
                                    <tr>
                                        <td style="text-align:left" title="@dat["Options"]">@dat["Options"].ToString().CutString(25)</td>
                                    </tr>                         
                                }
                            </table>
                        </td>
                        <td>
                            <table>
                                @foreach (System.Data.DataRow dat in dtTable.Rows)//循环取后两项
                                {
                                    <tr>
                                        <td style="text-align:left" title="@dat["Declares"].ToString()">
                                            @dat["Declares"].ToString().CutString(70)</td>
                                    </tr>                         
                                }
                            </table>
                        </td>
                    </tr>
                    }
                }
            </tbody>
        </table>
    </div>
</form>
<script type="text/javascript">
    var query = '@ViewBag.Query' + "&display=1";
    var dialog = top.mainDialog;
    var appid = '@ViewBag.AppID';
    var iframeid = '@ViewBag.Iframeid';
</script>
原文地址:https://www.cnblogs.com/zmmlczy/p/4498198.html