DataSet数据源可以复制,  DataSet ds2 = ds.Copy();

解决方案 »

  1.   

    这个并不是datatable,而是datagridtable,两者是不同的
      

  2.   

    1. bind the two datagrids to the same DataTable2. you have to write your own Clone() method by going through DataGrid's Items (or its underlying Table.Rows) and create new DataGridItem's and add them to your new DataGrid
      

  3.   

    to saucer(思归, MS .NET MVP):
    The 1:I change the data at runtime,so I can't bind the two datagrids to the same datatable
    The 2:I will try it,thx
      

  4.   

    THE1:运行时复杂怎吗不能BING到相同的数据原呢????可以的....
          其实就是重新绑定DG再刷新......AND OTHERS:
              myDt.clone; //复制数据表的架构不复制数据..          myDt.copy; //数据与架构一起复制.  
      

  5.   

    类似你的问题,我也遇见过,我的处理如下:
    1.利用DataGrid_Source的DataSet复制一个数据模式;
    1.利用DataGrid_Source构建一个DataTable,然后再绑定到DataGrid_Target中去;
    2.构建时要把DataGrid的items和DataTable的DataRow对应,DataGrid的Cell和DataTable的Cloumn相对应即可。
    一段代码仅供参考
    ds_target = ds_source.Clone();
    for ( int i = 0;i< DataGrid1.Items.Count; i++ )
    {
    DataRow dr = ds_target.Tables[0].NewRow();
    for(int j = 0; j < ds_target.Tables[0].Columns.Count;j++)
    {
    // Response.Write(DataGrid1.Items[i].Cells[j].Text + "//");
    dr[j] = DataGrid1.Items[i].Cells[j].Text; }
    ds_target.Tables[0].Rows.Add(dr);
    }
      

  6.   

    to saucer(思归, MS .NET MVP):
    success,thank you!