DataSet ds = new DataSet(); DataTable dt = new DataTable(); dt.TableName = "MyTable"; foreach (DataGridViewColumn col in dataGridView1.Columns) { dt.Columns.Add(col.DataPropertyName, col.ValueType); } foreach (DataGridViewRow gridRow in dataGridView1.Rows) { if (gridRow.IsNewRow) continue; DataRow dtRow = dt.NewRow(); for (int i1 = 0; i1 < dataGridView1.Columns.Count; i1++) dtRow[i1] = (gridRow.Cells[i1].Value == null ? DBNull.Value : gridRow.Cells[i1].Value); dt.Rows.Add(dtRow); } ds.Tables.Add(dt); System.Diagnostics.Debugger.Break();
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)