TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Peter Dzuya
NA
313
40.7k
iterating through rows in a girdview.
Aug 15 2017 4:15 AM
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.
Thanks
Peter Dzuya.
Reply
Answers (
4
)
How to define height and width for sub-menu stripe
How to dropdowns & datepickers change border color in C#