Repeater合并列

public static void MergeRows(Repeater gvw) //gvw 需要合并的Repeater
{
gvw.DataBind();
int rowcount = gvw.Items.Count;

if (rowcount == 0) { return; }

for (int rowIndex =rowcount-1; rowIndex > 0; rowIndex--)
{
//最后的ROW
RepeaterItem row = gvw.Items[rowIndex];
//之前ROW
RepeaterItem previousRow = gvw.Items[rowIndex - 1];
Label pname = (Label)row.FindControl("relapname1");
Label pscore = (Label)row.FindControl("replaxmsc");
Label npname = (Label)previousRow.FindControl("relapname1");
Label npscore = (Label)previousRow.FindControl("replaxmsc");
if (pname.Text != "" && pname.Text != "")
{
if ((pname.Text == npname.Text) && (pscore.Text == npscore.Text))
{//合并项目名称
HtmlTableCell oCell = row.FindControl("tdxmname") as HtmlTableCell;
HtmlTableCell oCell_previous = previousRow.FindControl("tdxmname") as HtmlTableCell;
oCell_previous.RowSpan =( oCell.RowSpan < 1 ? 2 : oCell.RowSpan + 1);
oCell.Visible = false;
//合并项目总分
HtmlTableCell oCellsc = row.FindControl("tdxmsc") as HtmlTableCell;
HtmlTableCell oCell_previoussc = previousRow.FindControl("tdxmsc") as HtmlTableCell;
oCell_previoussc.RowSpan = (oCell.RowSpan < 1 ? 2 : oCell.RowSpan + 1);
oCellsc.Visible = false;
}
}

}
}

posted @ 2013-05-04 22:41  cclient  阅读(169)  评论(0编辑  收藏  举报