2
I have a serious problem. I have a Gridview populated with data from a Mysql BD working perfectly.
I also have a button to turn it into a table to be inserted into a PDF using iTextSharp that also works perfectly, EXCEPT when I perform a date-specific filter on this Grid, even if the correct data is shown to me when performing the filter. I also have another type of filter that works perfectly when I try to generate PDF. Error occurs only when I set a date range, whatever. The message "Object Reference Not Set To An Instance Of An Object" appears is displayed and as much as you have already searched, I have not found solution for my case.
I leave here the part of the code that points the error.
The line "table.Addcell(new Phrase(dataGridView1[n, j].Value.Tostring());" is indicated by Visual Studio as the problem.
for (int j = 0; j < dataGridView1.Rows.Count; j++)
{
for (int n = 0; n < dataGridView1.Columns.Count; n++)
{
tabela.AddCell(new Phrase(dataGridView1[n, j].Value.ToString()));
tabela.HorizontalAlignment = 0;
tabela.WidthPercentage = 100;
}
}
Reinforcement: ONLY When I filter between dates, the error is shown!
The Code in question is on the PDF generate button.
Note: I am using Windowsform
Alias
NullReferenceException
.– Wtrmute