本帖最后由 ychchhy 于 2011-09-02 14:50:18 编辑

解决方案 »

  1.   

    http://blog.csdn.net/zhaoqiliang527/article/details/4490162
    动态添加表头
      

  2.   

    二、动态创建表头
    在GridView的RowCreated事件中,添加以下代码:
    //设计表头
    protected void SmartGridView1_RowCreated(object sender, GridViewRowEventArgs e)
    {
    if (e.Row.RowType == DataControlRowType.Header)
    {
    TableCellCollection header = e.Row.Cells;
    header.Clear();string headtxt = "名称</th>";
    headtxt += "<th colspan='4'>汇总</th>"; //跨四列
    headtxt += "<th>星期一</th><th>星期二</th><th>星期三</th><th>星期四</th>";
    headtxt = headtxt.Substring(0, headtxt.Length - 5); //移除掉最后一个</th>TableHeaderCell cell = new TableHeaderCell();
    cell.Attributes.Add("rowspan", "2"); //跨两行
    cell.Text = (headtxt);
    header.Add(cell);
    }
    }
      

  3.   

    列1,列2……已经是表头了,然后根据日期找出列4列5的内容,日期往后,列4列5重复显示。多表头在gridview里该怎么做?