Repeter中列相同数据合并

 1   <asp:Repeater runat="server" ID="rptInfo" onitemdatabound="Repeater1_ItemDataBound">
 2 
 3                 <HeaderTemplate>
 4 
 5                     <table cellpadding="0" cellspacing="0" border="1" bordercolor="black" width="100%" style="border-collapse: collapse; border-style: solid;">
 6 
 7                         <tr style=" font-weight:bold; text-align:center;">
 8 
 9                            <%-- <td>序号</td>--%>
10 
11                             <td  width="15%">单位名称</td>
12 
13                             <td>经营设施地址</td>
14 
15                             <td>核准内容</td>
16 
17                             <td>核准经营数量(吨/年)</td>
18 
19                             <td>处置方式</td>
20 
21                             <td>法定代表人</td>
22 
23                             <td>联系电话</td>
24 
25                             <td width="12%">有效期</td>
26 
27 
28                         </tr>
29                 </HeaderTemplate>
30 
31                 <ItemTemplate>
32 
33                     <tr>
34                         <%--<td runat="server" id="tdxuhao"></td>--%>
35                         
36                         <td runat="server" id="tdqiye_name" style="font-size:13px;"><%#Eval("qiye_name")%></td>
37 
38                         <td runat="server" id="tdDWDZ" style="font-size:13px;"><%#Eval("DWDZ")%></td>
39 
40                         <td runat="server" id="tdhzmc" style="font-size:13px; text-align:center;"><%#Eval("hzmc")%></td>
41 
42                         <td runat="server" id="tdmaxhpy" style=" text-align:center;font-size:13px;"><%#Eval("max_handle_per_year")%></td>
43 
44                         <td runat="server" id="tdczfs" style=" text-align:center;font-size:13px;"><%#Eval("czfs")%></td>
45 
46                         <td runat="server" id="tdFRDB" style="font-size:13px; text-align:center;"><%#Eval("FRDB")%></td>
47 
48                         <td runat="server" id="tdLXDH" style="font-size:13px; text-align:center;"><%#Eval("LXDH")%></td>
49 
50                          <td id="tdyxqt" runat="server" style=" text-align:center; font-size:13px;" ><%#Eval("firstTime", "{0:yyyy-MM-dd}")%>~<%#Eval("edittime", "{0:yyyy-MM-dd}")%></td>
51 
52                     </tr>
53 
54                 </ItemTemplate>
55 
56                 <FooterTemplate>
57                     </table>
58 
59                 </FooterTemplate>
60 
61             </asp:Repeater>
View Code
  1  public void getAllJYXKZ()
  2         {
  3             TGfgsJyxkzxxgsBizLogic jyxkz = new TGfgsJyxkzxxgsBizLogic();
  4             DataSet ds = jyxkz.GetALLSPSL();
  5             this.rptInfo.DataSource = ds;
  6             this.rptInfo.DataBind();
  7 
  8             for (int i = rptInfo.Items.Count - 1; i > 0; i--)
  9             {
 10 
 11 
 12                 //  HtmlTableCell xuhao_previous = rptInfo.Items[i].FindControl("tdxuhao") as HtmlTableCell;
 13                 // HtmlTableCell xuhao = rptInfo.Items[i-1].FindControl("tdxuhao") as HtmlTableCell;
 14 
 15 
 16                 HtmlTableCell oCell_previous = rptInfo.Items[i - 1].FindControl("tdqiye_name") as HtmlTableCell;
 17                 HtmlTableCell oCell = rptInfo.Items[i].FindControl("tdqiye_name") as HtmlTableCell;
 18 
 19                 oCell.RowSpan = (oCell.RowSpan == -1) ? 1 : oCell.RowSpan;
 20                 oCell_previous.RowSpan = (oCell_previous.RowSpan == -1) ? 1 : oCell_previous.RowSpan;
 21 
 22                 if (oCell.InnerText == oCell_previous.InnerText)
 23                 {
 24                     oCell.Visible = false;
 25                     oCell_previous.RowSpan += oCell.RowSpan;
 26 
 27                 }
 28 
 29 
 30 
 31 
 32                 HtmlTableCell DWDZprecious = rptInfo.Items[i - 1].FindControl("tdDWDZ") as HtmlTableCell;
 33                 HtmlTableCell DWDZ = rptInfo.Items[i].FindControl("tdDWDZ") as HtmlTableCell;
 34                 DWDZ.RowSpan = (DWDZ.RowSpan == -1) ? 1 : DWDZ.RowSpan;
 35                 DWDZprecious.RowSpan = (DWDZprecious.RowSpan == -1) ? 1 : DWDZprecious.RowSpan;
 36                 if (DWDZ.InnerText == DWDZprecious.InnerText)
 37                 {
 38                     DWDZ.Visible = false;
 39                     DWDZprecious.RowSpan += DWDZ.RowSpan;
 40                 }
 41 
 42 
 43                 HtmlTableCell hzmcprecious = rptInfo.Items[i - 1].FindControl("tdhzmc") as HtmlTableCell;
 44                 HtmlTableCell hzmc = rptInfo.Items[i].FindControl("tdhzmc") as HtmlTableCell;
 45                 hzmc.RowSpan = (hzmc.RowSpan == -1) ? 1 : hzmc.RowSpan;
 46                 hzmcprecious.RowSpan = (hzmcprecious.RowSpan == -1) ? 1 : hzmcprecious.RowSpan;
 47                 if (hzmc.InnerText == hzmcprecious.InnerText)
 48                 {
 49                     hzmc.Visible = false;
 50                     hzmcprecious.RowSpan += hzmc.RowSpan;
 51                 }
 52 
 53 
 54 
 55                 HtmlTableCell FRDBrecious = rptInfo.Items[i - 1].FindControl("tdFRDB") as HtmlTableCell;
 56                 HtmlTableCell FRDB = rptInfo.Items[i].FindControl("tdFRDB") as HtmlTableCell;
 57                 FRDB.RowSpan = (FRDB.RowSpan == -1) ? 1 : FRDB.RowSpan;
 58                 FRDBrecious.RowSpan = (FRDBrecious.RowSpan == -1) ? 1 : FRDBrecious.RowSpan;
 59 
 60                 if (FRDB.InnerText == FRDBrecious.InnerText)
 61                 {
 62                     FRDB.Visible = false;
 63                     FRDBrecious.RowSpan += FRDB.RowSpan;
 64                 }
 65 
 66                 HtmlTableCell LXDHrecious = rptInfo.Items[i - 1].FindControl("tdLXDH") as HtmlTableCell;
 67                 HtmlTableCell LXDH = rptInfo.Items[i].FindControl("tdLXDH") as HtmlTableCell;
 68                 LXDH.RowSpan = (LXDH.RowSpan == -1) ? 1 : LXDH.RowSpan;
 69                 LXDHrecious.RowSpan = (LXDHrecious.RowSpan == -1) ? 1 : LXDHrecious.RowSpan;
 70 
 71                 if (LXDH.InnerText == LXDHrecious.InnerText)
 72                 {
 73                     LXDH.Visible = false;
 74                     LXDHrecious.RowSpan += LXDH.RowSpan;
 75                 }
 76 
 77                 HtmlTableCell maxhpyrecious = rptInfo.Items[i - 1].FindControl("tdmaxhpy") as HtmlTableCell;
 78                 HtmlTableCell maxhpy = rptInfo.Items[i].FindControl("tdmaxhpy") as HtmlTableCell;
 79                 maxhpy.RowSpan = (maxhpy.RowSpan == -1) ? 1 : maxhpy.RowSpan;
 80                 maxhpyrecious.RowSpan = (maxhpyrecious.RowSpan == -1) ? 1 : maxhpyrecious.RowSpan;
 81 
 82                 if (maxhpy.InnerText == maxhpyrecious.InnerText)
 83                 {
 84                     if (oCell.InnerText == oCell_previous.InnerText)
 85                     {
 86                         maxhpy.Visible = false;
 87                         maxhpyrecious.RowSpan += maxhpy.RowSpan;
 88                     }
 89                 }
 90 
 91 
 92                 HtmlTableCell czfsrecious = rptInfo.Items[i - 1].FindControl("tdczfs") as HtmlTableCell;
 93                 HtmlTableCell czfs = rptInfo.Items[i].FindControl("tdczfs") as HtmlTableCell;
 94                 czfs.RowSpan = (czfs.RowSpan == -1) ? 1 : czfs.RowSpan;
 95                 czfsrecious.RowSpan = (czfsrecious.RowSpan == -1) ? 1 : czfsrecious.RowSpan;
 96 
 97 
 98 
 99                 if (czfs.InnerText == czfsrecious.InnerText)
100                 {
101                     if (oCell.InnerText == oCell_previous.InnerText)
102                     {
103                         czfs.Visible = false;
104                         czfsrecious.RowSpan += czfs.RowSpan;
105                     }
106                 }
107 
108 
109 
110 
111 
112                 HtmlTableCell yxqtrecious = rptInfo.Items[i - 1].FindControl("tdyxqt") as HtmlTableCell;
113                 HtmlTableCell yxqt = rptInfo.Items[i].FindControl("tdyxqt") as HtmlTableCell;
114                 yxqt.RowSpan = (yxqt.RowSpan == -1) ? 1 : yxqt.RowSpan;
115                 yxqtrecious.RowSpan = (yxqtrecious.RowSpan == -1) ? 1 : yxqtrecious.RowSpan;
116 
117                 if (yxqt.InnerText == yxqtrecious.InnerText)
118                 {
119                     yxqt.Visible = false;
120                     yxqtrecious.RowSpan += yxqt.RowSpan;
121                 }
122 
123 
124 
125 
126 
127             }
128         }
View Code

 

posted @ 2015-04-10 15:15  Jbp  阅读(381)  评论(0编辑  收藏  举报