1 //先判断是否有勾选行,有勾选则只导出勾选的行。
 2                 //定义和DataGridView控件内容结构相同的DataTable
 3                 //dtCartClo是DataGridView的数据源
 4                 DataTable dtDgv = this.dtCartClo.Clone();//
 5                 foreach (DataGridViewRow dgRow in this.dgvxCtnPOC.Rows)
 6                 {
 7                     if (dgRow.Cells["选择"].Value != null && dgRow.Cells["选择"].Value.ToString().ToLower() == "true")
 8                     {
 9                         DataRow newRow = this.dtCartClo.NewRow();
10                         foreach (DataColumn col in this.dtCartClo.Columns)
11                         {
12                             if (col.ColumnName == "ClothingID")
13                             {
14                                 newRow[col.ColumnName] = Convert.ToInt32(dgRow.Cells[col.ColumnName].Value);
15                             }
16                             else
17                             {
18                                 newRow[col.ColumnName] = dgRow.Cells[col.ColumnName].Value.ToString();
19                             }
20                         }
21                         dtDgv.Rows.Add(newRow.ItemArray);
22                     }
23                 }

 

posted on 2013-12-04 11:42  清风暮雨  阅读(1346)  评论(0)    收藏  举报