Thank you so much for this forum.
I have a gridview which I have used to import data from Microsoft excel.Now I want to pick selected colums and save them into my database. I have used the following code.
foreach (DataGridViewRow dgvr in dataGridView1.Rows){
DataRow dr = ((DataRowView)dgvr.DataBoundItem).Row;
if (dr["BOXNO"].ToString() != null) {
var boxNumber = dr["BOXNO"].ToString();
var dateOfSale = dr["DATEOFSALE"].ToString();
var broker = dr["BROKER"].ToString();
var lotNumber = dr["LOTNO"].ToString();
var gden = dr["GARDENMARK"].ToString();
var invoiceNumber = dr["INVOICENO"].ToString();
}
}
It iterates all records well, but then I get the following exception "Object referencenot set to an instanceod an object".
Please assist.