首页 > 代码库 > gridview 合并列

gridview 合并列

 

    //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 =http://www.mamicode.com/= hidpersonname1.Value && HidSign.Value == HidSign1.Value && hidUnitID.Value == hidUnitID1.Value && Hiduintnum.Value == Hiduintnum1.Value)"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;                //    }                //}                //}            }        }    }