ITPub博客

首页 > Linux操作系统 > Linux操作系统 > Gridview表头(跨行、跨列)显示样式!

Gridview表头(跨行、跨列)显示样式!

原创 Linux操作系统 作者:iDotNetSpace 时间:2009-04-23 16:20:36 0 删除 编辑

下面就是实现这个的代码:

protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.Header)
        {
            TableCellCollection tcHeader = e.Row.Cells;
            tcHeader.Clear();//原有表头清空

            tcHeader.Add(new TableHeaderCell());
            tcHeader[0].Attributes.Add("rowspan", "2");               
            tcHeader[0].Text = "县(市)、区";
            tcHeader[0].Width = 130;

            tcHeader.Add(new TableHeaderCell());
            tcHeader[1].Attributes.Add("rowspan", "2");            
            tcHeader[1].Text = "合计";
            tcHeader[1].Width = 30;

            tcHeader.Add(new TableHeaderCell());
            tcHeader[2].Attributes.Add("colspan", "2");   
            tcHeader[2].Text = "新生儿情况";
            tcHeader[2].Width = 100;

            tcHeader.Add(new TableHeaderCell());
            tcHeader[3].Attributes.Add("colspan", "3");   
            tcHeader[3].Text = "新生儿性别";
            tcHeader[3].Width = 100;

            tcHeader.Add(new TableHeaderCell());
            tcHeader[4].Attributes.Add("colspan", "2");   
            tcHeader[4].Text = "生育证";

            tcHeader.Add(new TableHeaderCell());
            tcHeader[5].Attributes.Add("colspan", "2");  
            tcHeader[5].Text = "出生医学证明";
            tcHeader[5].Width = 130;

            tcHeader.Add(new TableHeaderCell());
            tcHeader[6].Attributes.Add("rowspan", "2");   
            tcHeader[6].Text = "备注";

            tcHeader.Add(new TableHeaderCell());
            tcHeader[7].Text = "活产";
            tcHeader[7].Width = 60;

            tcHeader.Add(new TableHeaderCell());
            tcHeader[8].Text = "死产";
            tcHeader[8].Width = 60;

            tcHeader.Add(new TableHeaderCell());
            tcHeader[9].Text = "男";
            tcHeader[9].Width = 60;

            tcHeader.Add(new TableHeaderCell());
            tcHeader[10].Text = "女";
            tcHeader[10].Width = 60;

            tcHeader.Add(new TableHeaderCell());
            tcHeader[11].Text = "性别比";
            tcHeader[11].Width = 60;

            tcHeader.Add(new TableHeaderCell());
            tcHeader[12].Text = "有";
            tcHeader[12].Width = 60;

            tcHeader.Add(new TableHeaderCell());
            tcHeader[13].Text = "无";
            tcHeader[13].Width = 60;

            tcHeader.Add(new TableHeaderCell());
            tcHeader[14].Text = "已办理";
            tcHeader[14].Width = 60;

            tcHeader.Add(new TableHeaderCell());
            tcHeader[15].Text = "未办理";
            tcHeader[15].Width = 60;
        }
    }

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/12639172/viewspace-591576/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2008-01-04

  • 博文量
    2376
  • 访问量
    5309098