ASPForums.Net RSS Feedhttp://www.aspforums.net/Handlers/RSS.ashxLatest additions to the content that appears on ASPForums.Net(c) 2019 www.aspforums.com. All rights reserved.Export DataGridView to PDF Error: Object reference not set to an instance of an object in VB.Net<p>1) <strong>First Debug the code to check the cell.value value</strong> if it&rsquo;s null or empty it will throw NullReferenceException error.</p> <p>2) Use Convert.ToString to convert the nullable string values so it will not throw such error. Or you can check the cell value using string.IsNullOrEmpty to handle nullable error.</p> <p>Check the below Modified line code and implement it as per your code logic.</p> <p><span style="text-decoration: underline;"><strong>C#</strong></span></p> <pre class="brush: csharp">pdfTable.AddCell(Convert.ToString(cell.Value)); // or Below line code if you need to assign any default value if its null // here i assign empty string value if cell.Value is null or empty pdfTable.AddCell(!string.IsNullOrEmpty(cell.Value) ? Convert.ToString(cell.Value) :&#34;&#34;);</pre> <p><span style="text-decoration: underline;"><strong>VB.Net</strong></span> </p> <pre class="brush: vb">pdfTable.AddCell(Convert.ToString(cell.Value)) &#39; or Below line code if you need to assign any default value if its null &#39; here i assign empty string value if cell.Value is null or empty pdfTable.AddCell(If(Not String.IsNullOrEmpty(cell.Value), Convert.ToString(cell.Value), &#34;&#34;))</pre> <p>&nbsp;</p>https://www.aspforums.net:443/Threads/142392/Export-DataGridView-to-PDF-Error-Object-reference-not-set-to-an-instance-of-an-object-in-VBNet/https://www.aspforums.net:443/Threads/142392/Export-DataGridView-to-PDF-Error-Object-reference-not-set-to-an-instance-of-an-object-in-VBNet/Fri, 05 Jan 2018 06:19:51 GMT