码迷,mamicode.com
首页 > 其他好文 > 详细

gridview 合并列

时间:2014-07-16 15:06:14      阅读:221      评论:0      收藏:0      [点我收藏+]

标签:blog   os   art   for   div   re   

 

    //gridview 相同列合并
    private void GroupRows(GridView grv)
    {
        string[] drs = { "ConferenceStartDate", "ddd" };
        int num = 1;
        for (int j = num - 1; j < grv.Rows.Count - 1; j++) //循环行
        {
            int r = 1;
            num = 1;
            GridViewRow gvr = grv.Rows[j];//前一行的单元格
            for (int i = j + 1; i < grv.Rows.Count; i++)//下一行
            {

                if (r < 2)
                {
                    GridViewRow gvrNext = grv.Rows[i];
                    HiddenField hidpersonname = grv.Rows[j].FindControl("hidpersonname") as HiddenField;
                    HiddenField HidSign = grv.Rows[j].FindControl("HidSign") as HiddenField;
                    HiddenField hidUnitID = grv.Rows[j].FindControl("hidUnitID") as HiddenField;
                    HiddenField Hiduintnum = grv.Rows[j].FindControl("Hiduintnum") as HiddenField;

                    HiddenField hidpersonname1 = grv.Rows[i].FindControl("hidpersonname") as HiddenField;
                    HiddenField HidSign1 = grv.Rows[i].FindControl("HidSign") as HiddenField;
                    HiddenField hidUnitID1 = grv.Rows[i].FindControl("hidUnitID") as HiddenField;
                    HiddenField Hiduintnum1 = grv.Rows[i].FindControl("Hiduintnum") as HiddenField;
                    //Label lID1 = grv.Rows[j].FindControl("lbID" + drs[r].ToString()) as Label;
                    //Label lID2 = grv.Rows[i].FindControl("lbID" + drs[r].ToString()) as Label;
                    //Label l1 = grv.Rows[j].FindControl("lbSign" + drs[r].ToString()) as Label;
                    //Label l2 = grv.Rows[i].FindControl("lbSign" + drs[r].ToString()) as Label;
                    if (hidpersonname.Value == hidpersonname1.Value && HidSign.Value == HidSign1.Value && hidUnitID.Value == hidUnitID1.Value && Hiduintnum.Value == Hiduintnum1.Value)
                    {
                        num += 1;
                        gvrNext.Cells[r + 1].Visible = false;
                        gvr.Cells[r + 1].RowSpan = num;
                    }
                    else
                    {
                        num = 1;
                        break;
                    }
                }
                //else
                //{
                //    GridViewRow gvrNext = grv.Rows[i];
                //    Label lID1 = grv.Rows[j].FindControl("lbID" + drs[r].ToString()) as Label;
                //    Label lID2 = grv.Rows[i].FindControl("lbID" + drs[r].ToString()) as Label;
                //    Label l1 = grv.Rows[j].FindControl("lbSign" + drs[r].ToString()) as Label;
                //    Label l2 = grv.Rows[i].FindControl("lbSign" + drs[r].ToString()) as Label;
                //    Label lbWork1 = grv.Rows[j].FindControl("lbWork" + drs[r].ToString()) as Label;
                //    Label lbWork2 = grv.Rows[i].FindControl("lbWork" + drs[r].ToString()) as Label;
                //    if (l1.Text == l2.Text && lID1.Text == lID2.Text && lbWork1.Text == lbWork2.Text)
                //    {
                //        num += 1;
                //        gvrNext.Cells[r + 1].Visible = false;
                //        gvr.Cells[r + 1].RowSpan = num;
                //    }
                //    else
                //    {
                //        num = 1;
                //        break;
                //    }
                //}
                //}
            }
        }

    }

  

gridview 合并列,布布扣,bubuko.com

gridview 合并列

标签:blog   os   art   for   div   re   

原文地址:http://www.cnblogs.com/wjwei/p/3848269.html

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