用DataTable来装数据,只要是选中了控件里的值,就把值保存到DataTable 中,但是又不能把以前的数据覆盖,我的代码是这样:我在后台编码中.cs文件中声明了变量:
DataTable mytable = new DataTable();
DataColumnCollection mycolumns;
DataRow mydr;然后 在button_click事件中做如下操作:mydr = mytable.NewRow();
mycolumns = mytable.Columns;
mycolumns.Add("NUM", typeof(int));
mycolumns.Add("NAME", typeof(string));
mycolumns.Add("TAG",typeof(string));for ( int i = 0; i < this.UltraWebGrid1.DisplayLayout.Rows.Count; i ++ )
{
    if ( this.UltraWebGrid1.Rows[i].Selected )
    {
       mydr["NUM"] = this.UltraWebGrid1.Rows[i].Cells[0].Value;
       mydr["NAME"] = this.UltraWebGrid1.Rows[i].Cells[1].Value;
       mydr["TAG"] = this.UltraWebGrid1.Rows[i].Cells[2].Value;
       mytable.Rows.Add(mydr);       this.UltraWebGrid2.DataSource = mytable;
       this.UltraWebGrid2.DataBind();
     }
}为什么我第二次点击button的时候,DataTable 里的第二条数据将第一条数据覆盖了呢,而且始终都是一条数据?