assume you are talking about the DataGrid in ASP.NET, >>>给控件添加行
add extra rows to your DaTable>>>控件添加列
add additional Cell to DataGridItemEventArgs.Item.Cells collection in ItemCreated or ItemDataBound event handler>>>怎样得到某单元的值
use DataGrid.Items[nIndex].Cells[n].Text

解决方案 »

  1.   

    sorryadd extra rows to your DaTable
    ===>
    add extra rows to your DataTable
      

  2.   

    我用的是winform不是ASP.NET中的,另外,能不能不用绑定的方法去对数据对象去改变 而是直接通过DataGrid的一些对象或属性来解决?
      

  3.   

    设定DataGrid的DataSource属性,给他一个继承CollectionBase类的对象DataGrid中的各列就是根据你自己写的数据对象的属性来定义的
      

  4.   

    很简单的
    在DataGrid的DataSet中的表中增加行列即可
    DataGrid DG;
    Ds = new DataSet("Ds");
    Ds.Tables.Add(new DataTable("Tab"));//
    //动态添加列
    DCol              = new DataColumn();
    DCol.DataType     = System.Type.GetType("System.String");
    DCol.ColumnName   = "日期";
    DCol.Caption      = "日期";
    Ds.Tables["Tab"].Columns.Add(DCol);//
    //动态添加行
    DRow = Ds.Tables["Tab"].NewRow();
    Ds_Kh.Tables["Tab_Kh"].Rows.Add(DRow);DG.DataSource = Ds;
    DG.DataBind();