0

我有一个 Janus Grid,每行都有一个复选框,并且想将选定的行复制到 DataRowCollection 或 DataRow[] 。这是我的方式,但没有完成,也没有工作:这个网格在一个字段上也有组,我使用2 组和孩子的循环。

gridEX1.DataSource = dtALL;//dtALL is a data table fill with select sql command
DataRowCollection dr    
DataRow dr2=dtALL.NewRow();
foreach (Janus.Windows.GridEX.GridEXRow g in gridEX1.GetRows())
{
   foreach (Janus.Windows.GridEX.GridEXRow r in g.GetChildRows())
   {
      if ((bool)r.Cells["sendALL"].Value == true && r.Cells["DocTitle"].Value.ToString() == DocTitle)
        {
           for(int i=0;i<r.Cells.Count;i++)
             if(r.Cells[i].GetType()==typeof(TextBox))
             {
                 dr2[i] = r.Cells[i].Value;
             }
             dr.Add(dr2);
         }
    }
}
4

1 回答 1

1

我想出了这种方法并解决了我的问题:

DataTable dt1copy = new DataTable();
dt1copy.Columns.Add("DocTitle");
dt1copy.Columns.Add("DocDetails");
dt1copy.Columns.Add("ExpLenght");
dt1copy.Columns.Add("ReqDate");
dt1copy.Columns.Add("ReqTypeDetailsTitle");
dt1copy.Columns.Add("ReqTypeTitle");
dt1copy.Columns.Add("UnitsTitle");
dt1copy.Columns.Add("DocType");
dt1copy.Columns.Add("DocSuffix");
dt1copy.Columns.Add("FKGID");
dt1copy.Columns.Add("Id");//id of docinreq tbl
DataRow dr2;
DataRowCollection dr = dt1copy.Rows;

string DocTitle = gridEX1.CurrentRow.Cells["DocTitle"].Value.ToString();
foreach (Janus.Windows.GridEX.GridEXRow g in gridEX1.GetRows())
{
   foreach (Janus.Windows.GridEX.GridEXRow r in g.GetChildRows())
   {
      try
      {
          if ((bool)r.Cells["sendALL"].Value == true && r.Cells["DocTitle"].Value.ToString() == DocTitle)
            {
               dr2 = dt1copy.NewRow();
               for (int i = 0, j = 0; i < r.Cells.Count; i++)
               {
                   if (r.Cells[i].Column.BoundMode != Janus.Windows.GridEX.ColumnBoundMode.UnboundFetch)//select only bounded column from grid
                   {
                       dr2[j] = r.Cells[i].Value.ToString();
                       j++;
                   }
              }
              dt1copy.Rows.Add(dr2);
           }
        }
        catch (Exception) { }
     }
  }
 dr = dt1copy.Rows;
于 2021-08-02T05:41:03.403 回答