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
Farrukh Javeid
NA
38
0
How to retrieve data from grid view in .NET
Jul 21 2010 11:28 AM
Hello,
I have been trying to get the values from DataGridView. My stupid logic works a bit when accessing the individual cells of the Data Grid Row.
This is the the code that I am using.
private void btn_fetch_Click(object sender, EventArgs e)
{
string result = "";
string part1 = "";
string part2 = "";
for (int i = 1; i <= DGV_CsvFile.Rows.Count; i++)
{
part1 = DGV_CsvFile.Rows[i].Cells[0].Value.ToString();
part2 = DGV_CsvFile.Rows[i].Cells[1].Value.ToString();
result =result + part1+" : "+part2+"\n";
}
}
But the problem comes when it completes its iteration, the following exception comes on my face. :(
"Object reference not set to an instance of an object."
and it selects the first line of the loop.
Need urgent help fellows.
Thanx in advance.
Reply
Answers (
2
)
GET MAC ID
still looking for removing row from datagridview in window application.