首页 新闻 搜索 专区 学院

合并单元格分页

0
[已关闭问题]

代码如下:

 protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        GridView1.PageIndex = e.NewPageIndex;
        GridView1.DataBind();
    }

    private void GridViewFill(GridViewRowEventArgs e)
    {
        //获得部门Id
 
        string departId = DataBinder.Eval(e.Row.DataItem, "UserInfo.departId").ToString();
        DepartInfo depart = GetComponent.DepartInfoManager.FindDepartInfoById(int.Parse(departId));
        e.Row.Cells[0].Text = depart.UserInfo.UserName;
        e.Row.Cells[4].Text = depart.DepartName;
        e.Row.Cells[5].Text = depart.BranchInfo.BranchName;
        //获得签卡标记
        e.Row.Cells[2].Text = (e.Row.Cells[2].Text.Trim().Equals("1")) ? "签到" : "签退";
        //获得签卡描述
        string signDesc = e.Row.Cells[3].Text.Trim();
     
      
    }

  protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {

        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            GridViewFill(e);
        }

  }

 //单元格的处理
    private void UnitOperate(GridView gridView)
    {
        string saveCell;//保存列
        int lastCell;//最终列    
        if (gridView.Rows.Count > 0)
        {
            for (int i = 0; i < 6; i++)
            {
                //排除不合并的单元格
                if (i != 1 && i != 2 && i != 3)
                {
                    saveCell = gridView.Rows[0].Cells[i].Text;//获得第一行需合并数据
                    gridView.Rows[0].Cells[i].RowSpan = 1;//设初始合并值为1,每遇重复行自加并移动的新的行号获取数据
                    lastCell = 0;

                    for (int temp = 1; temp < gridView.Rows.Count; temp++)
                    {   //发现重复行将其合并
                        if (gridView.Rows[temp].Cells[i].Text == saveCell)
                        {
                            gridView.Rows[temp].Cells[i].Visible = false;
                            gridView.Rows[lastCell].Cells[i].RowSpan++;//合并
                        }
                        else
                        {//下一条用户记录
                            saveCell = gridView.Rows[temp].Cells[i].Text;//将其第一条记录保留,作为下一次比较用
                            lastCell = temp;//把行号保存
                            gridView.Rows[temp].Cells[i].RowSpan = 1;//开始新合并行
                        }
                    }
                }
            }
        }
    }

 

 

我已经成功的合并单元格了。。但是分页以后。发现点击第2页没有东西。。。哪位大哥可以帮帮我这位新手

naiping的主页 naiping | 初学一级 | 园豆:200
提问于:2010-04-20 15:26
< >
分享
其他回答(1)
0

合并单元格应该用脚本在前台来实现,可以看看我的博客

高凡凡高 | 园豆:95 (初学一级) | 2010-04-23 21:48
0

请问楼主,上面的问题解决了吗?能讲讲大概是怎样的实现思路吗?

熙冠 | 园豆:95 (初学一级) | 2013-05-17 21:14
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册