object cannot be cast from dbnull to other types
var bindingsource = (BindingSource)dgv_summary.DataSource; DataTable tbl = ((DataTable)bindingsource.DataSource).Clone(); var rows = dgv_summary.Rows.OfType<DataGridViewRow>() .Where(r => Convert.ToBoolean(r.Cells[" "].Value)) .Select(r => ((DataRowView)r.DataBoundItem).Row); foreach (var row in rows) { tbl.ImportRow(row); } DataTable dt_Cust = tbl.DefaultView.ToTable(true, "GL_ACNO");
var rows = dgv_summary.Rows.OfType<DataGridViewRow>() .Where(r => GetBoolValue( r.Cells[" "].Value)) .Select(r => ((DataRowView)r.DataBoundItem).Row);
private bool GetBoolValue(object value) { string val = Convert.ToString(value); bool returnValue ; Boolean.TryParse(val, out returnValue); return returnValue; }
r => Convert.ToBoolean(r.Cells[" "].Value)
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)