乏mily

导航

Repeater中table行的合同

前台代码:

<asp:Repeater runat="server" ID="rptInfo">
    <HeaderTemplate>
        <table class="content" border="1" cellspacing="0" cellpadding="5" style="border-collapse: collapse;
            width: 100%;">
            <tr>
                <td>序号</td>
                <td>项目编码</td>
                <td>项目名称</td>
                <td>分配单位</td>
                <td>工作内容</td>
                <td>备注</td>
            </tr>
    </HeaderTemplate>
    <ItemTemplate>
            <tr>
                <td><%# Container.ItemIndex+1 %></td>
          <td runat="server" id="td_ProCom"><%# Eval("ProCom")%></td>
                <td><%# Eval("ProjectID")%></td>
         <
td><%# Eval("ProjectName")%></td> <td><%# Eval("Procontent")%></td> <td><%# Eval("Remarks")%></td> </tr> </ItemTemplate> <FooterTemplate> </table> </FooterTemplate> </asp:Repeater>

后台绑定代码:

protected void Page_Load(object sender, EventArgs e)
{
      XieKe.BLL.tb_PlanDetail tbplanD = new BLL.tb_PlanDetail();
      DataSet ds = new DataSet();     
      ds = tbplanD.GetList();
   //当ds中只有一张表时
  
if(ds.Tables[0].Rows.Count>0) { this.Repeater1.DataSource = ds.Tables[0]; this.Repeater1.DataBind(); }
    //重要的是下面这段代码
for (int i = Repeater1.Items.Count-1; i > 0; i--) { HtmlTableCell oCell_previous = Repeater1.Items[i - 1].FindControl("td_ProCom") as HtmlTableCell; HtmlTableCell oCell = Repeater1.Items[i].FindControl("td_ProCom") as HtmlTableCell; oCell.RowSpan = (oCell.RowSpan == -1) ? 1 : oCell.RowSpan; oCell_previous.RowSpan = (oCell_previous.RowSpan == -1) ? 1 : oCell_previous.RowSpan; if (oCell.InnerText == oCell_previous.InnerText) { oCell.Visible = false; oCell_previous.RowSpan += oCell.RowSpan; } } }

 

 

 

 

 

 

 

 

参考博文:

Repeater控件动态变更列(Header,Item和Foot)信息:

http://www.cnblogs.com/insus/archive/2013/03/22/2974970.html

重构《Repeater控件动态变更列(Header,Item和Foot)信息》:

http://www.cnblogs.com/insus/archive/2013/03/22/2975824.html

动态合并或定制GridView控件Header头某些列:

http://www.cnblogs.com/insus/p/3232391.html

动态合并GridView数据行DataRow的列:

http://www.cnblogs.com/insus/p/3238348.html

动态合并Repeater控件数据列:

http://www.cnblogs.com/insus/p/3240848.html

posted on 2013-09-25 15:47  乏mily  阅读(152)  评论(0)    收藏  举报