DataGrid控件通过预定义的属性和委派,没有包含双标题的特性

解决方案 »

  1.   

    不过如果你不用分页
    或者能够接受分页在定上
    你可以得到在footer 之下的那个page
      

  2.   

    里面放Table控件就可以任定制外观
      

  3.   

    那这样说Header也不能是两行的了?
      

  4.   

    解决不了的问题,我也遇到过,还有就是在datagrid中的每个单元个的输出中能否在数据之前加一个空格?
      

  5.   

    定义模版列的时候            
    Dim Tc1 As New TemplateColumn()
                Dim checkbg As New Label()
                Dim container As New Control()
                container.Controls.Add(checkbg)
                Tc1.ItemTemplate.InstantiateIn(container)
                Me.DataGrid1.Columns.Add(Tc1)在 Tc1.ItemTemplate.InstantiateIn(container)
    时候说对象没有引用到实例,为什么,谢谢?
      

  6.   

    TO: GaoFX(紫龙) 
        请说详细点好么?加入模板要怎么加呢?
      

  7.   

    生成两行的Header是绝对可以的,生成两行的Footer没试过
      

  8.   

    在ItemDataBound事件中
    if (e.Item.ItemType==ListItemType.Footer)
    {
    tr=new TableRow();
    td=new TableCell();
    td.ColumnSpan=e.Item.Cells.Count;
    td.Text="No2";
    tr.Cells.Add(td);
    DataGrid1.Item.Add(tr);
    }嗯,没测试过的,你看看行不行把
      

  9.   

    谢谢yxrj(),我现在就试!
    另外:以下这个问题也是急需的,请各位也帮帮忙!定义模版列的时候            Label label=new Label();
    Control con=new Control();
    TemplateColumn tc=new TemplateColumn();
    tc.ItemTemplate.InstantiateIn(con);
    con.Controls.Add(label);
    DataGrid1.Columns.Add(tc);在tc.ItemTemplate.InstantiateIn(con);时候说对象没有引用到实例
      

  10.   

    http://www20.brinkster.com/icyer/ItemTemplate/ItemTemplate.htm
      

  11.   

    可以放一个Table进去,要任意多行列都可以,但是现在有一个问题,就是只能把Table和到Footer行的一个单元格里面,怎么把Footer行合并成一个单元格呢?
    这样只是把一个二行五列的Table和到第一个单元格里,多出来的四个单元格怎么处理呢?//生成Table
    private Table creat_table(int n)
    {
         Table table1=new Table();
         for(int i=0;i<2;i++)
         {
    TableRow tr=new TableRow();
    for(int j=0;j<5;j++)
    {
    TableCell td=new TableCell();
                      td.ColumnSpan=n;
    td.Text="No"+i.ToString()+j.ToString();
    tr.Cells.Add(td);
    }
    table1.Controls.Add(tr);
         }
    }private void DataGrid1_ItemDataBound(object sender, DataGridItemEventArgs e)
    {
        if (e.Item.ItemType==ListItemType.Footer)
        {
    e.Item.Cells[1].ColumnSpan=e.Item.Cells.Count;
    e.Item.Cells[1].Controls.Add(creat_table(e.Item.Cells.Count)); 
        }
    }
      

  12.   

    e.Item.Cells[1].ColumnSpan=e.Item.Cells.Count;
    e.Item.Cells[1].Controls.Add(creat_table(e.Item.Cells.Count));
    for (int i = 2; i < e.Item.Cells.Count; i++)
     e.Item.Cells.RemoveAt(2);
      

  13.   

    是否一定要在Footer的每个单元格里插入才行?
      

  14.   

    怎么这么奇怪,加上这个是可以删除,但是为什么只删除一部分?还有两个单元格没有删掉??
    for (int i = 2; i < e.Item.Cells.Count; i++)
     e.Item.Cells.RemoveAt(2);
      

  15.   

    为什么?Response.Write(e.Item.Cells.Count.ToString());  //输出为6
    for (int i = 2; i < e.Item.Cells.Count; i++)
    e.Item.Cells.RemoveAt(2);
    Response.Write(e.Item.Cells.Count.ToString());  //输出为4
      

  16.   

    可以了,把循环里的e.Item.Cells.Count改成6就行了,谢谢各位!
      

  17.   

    删除了几个之后,当然就是4了,至于需要删除哪几个,你可以自己试试。
    只是需要注意的是,删除一个之后,后面的Cell的Index都会减1。