I have a webservice which populates my DataGridView using a couple of webmethods.
Without this code everything works great but I need the picture to change depending on the row selected and the name of the picture will be in a static column that will not change.
What I am trying to do is, in my webmethod, send it a picture name equal to picture1.jpg.
In the windows application I am using this code:
int i;
i = memdataGV.SelectedCells[0].RowIndex;
var pictext = memdataGV.Rows[i].Cells[5].Value.ToString();
pictureBox1.ImageLocation = "C:\\Pictures\\" + pictext;
When the DataGridView first populates everything works fine but when I click on one of my button events it throws an exception on the following line:
var pictext = memdataGV.Rows[i].Cells[5].Value.ToString();
NullReferenceException was unhandled
I tried to debug the code and I added the if statement to the top however does not seem to fix it.
Figured it out for some reason the index 5 was returning null and there was a value in the cell. So I did code to grab the value by the column name which found the value and is working