哪位能告诉我怎样用WEBForm的DataGrid实现跨多列同时跨多行的表!
小弟跪求大虾了。
急用啊 !有代码最好了

解决方案 »

  1.   

    首先,为DataTable添加一个空行:
    objDS=new DataSet();
    objDS=DataAccess.ExecProc(procName);
    //添加空DataRow,并排序
    DataTable dt=objDS.Tables[0];
    DataRow dr=dt.NewRow();
    dt.Rows.Add(dr);
    DataView myDataView = dt.DefaultView;
    myDataView.Sort = "AreaName ASC";
    this.dgDeposit.DataSource =dt;
    this.dgDeposit.DataBind();接着,对表头进行处理:
    Private void dgDeposit_ItemDataBound(object sender,DataGridItemEventArgs e)
    {
    flag++;
    if(flag==1)//处理原表头
    {
    for(int i=0;i<=4;i++)
    {
    e.Item.Cells[i].RowSpan =2;
    } e.Item.Cells[5].ColumnSpan =2;
    e.Item.Cells[5].Text =title;
    e.Item.Cells[5].HorizontalAlign =HorizontalAlign.Center;//由于某些单元格占用了多列多行,会将原有的单元格向右挤,须删去
    for(int i=0;i<1;i++)
    {
    e.Item.Cells.RemoveAt(6);
    }
    }
    else if(flag==2)//处理新插入的空行,以作多行表头
    {
    for(int i=0;i<2;i++)
    {
    e.Item.Cells[i].Text =sArray[i];
    e.Item.Cells[i].Width =Unit.Pixel(50);
    e.Item.Cells[i].BackColor =Color.RoyalBlue;
    } //由于某些单元格占用了多列多行,会将原有的单元格向右挤,须删去
    for(int i=0;i<5;i++)
    {
    e.Item.Cells.RemoveAt(2);
    }
    }
    }这是我以前写的,你自己看看改改吧