zoukankan      html  css  js  c++  java
  • Gridview后台自定义添加表头

    代码写入事件:gridview_RowCreated

    switch (e.Row.RowType)
    {
    case DataControlRowType.Header://类型为header
    //第一行表头
    TableCellCollection tcHeader = e.Row.Cells;//TableCellCollection单元格的集合
    tcHeader.Clear();
    tcHeader.Add(new TableHeaderCell());
    tcHeader[0].Attributes.Add("bgcolor", "Red");
    tcHeader[0].Attributes.Add("colspan", "4");//占4个列
    tcHeader[0].Text = "全部信息</tr><tr>";
    tcHeader[0].HorizontalAlign = HorizontalAlign.Center;//居中显示
    
    //第二行表头
    tcHeader.Add(new TableHeaderCell());
    tcHeader[1].Attributes.Add("bgcolor", "DarkSeaGreen");
    tcHeader[1].Attributes.Add("rowspan", "2");
    tcHeader[1].Text = "主键";
    tcHeader.Add(new TableHeaderCell());
    tcHeader[2].Attributes.Add("bgcolor", "LightSteelBlue");
    tcHeader[2].Attributes.Add("colspan", "3");
    tcHeader[2].Text = "基本信息</tr><tr>";
    
    
    //第三行表头
    tcHeader.Add(new TableHeaderCell());
    tcHeader[3].Attributes.Add("bgcolor", "Khaki");
    tcHeader[3].Text = "身份证号码";
    tcHeader.Add(new TableHeaderCell());
    tcHeader[4].Attributes.Add("bgcolor", "Khaki");
    tcHeader[4].Text = "数字";
    tcHeader.Add(new TableHeaderCell());
    tcHeader[5].Attributes.Add("bgcolor", "Khaki");
    tcHeader[5].Text = "出生日期</tr>";
    break;
    
    }
    
    

     运行结果: 

    主键为空是因为数据库不存在数据;出生日期是Guid 。

    在这里感谢大唐的方平详细的为我调式讲解 手写html Table原理,不知道他现在还好不。

  • 相关阅读:
    BZOJ 4033: [HAOI2015]树上染色 (树形DP)
    BZOJ 1820: [JSOI2010]Express Service 快递服务 DP
    BZOJ 4664: Count 插块DP
    BZOJ 1899: [Zjoi2004]Lunch 午餐 DP
    BZOJ 4559 [JLoi2016]成绩比较 (DP+拉格朗日插值)
    BZOJ1485 [HNOI2009] 有趣的数列 (卡特兰数)
    BZOJ 2111 / Luogu P2606 [ZJOI2010]排列计数
    20190915模拟赛
    深海机器人问题
    太空飞行计划问题
  • 原文地址:https://www.cnblogs.com/y112102/p/2563940.html
Copyright © 2011-2022 走看看