mysql - How to change the color of a cell of Datagridview by comparing the cell date with today's Date in C#.net? -
i new c#,this first project on c# language , backend mysql, stuck @ particular point ,i having form containing datagridview binded database value,in have column "tns_date" expiration date of product ,i want if tns_date greater current date background colour of particular cell should red in colured ,how ,please me this i using winforms , till had tried foreach (datagridviewrow row in tnsformdgv.rows) { var = datetime.now; var expirationdate = datetime.parse(row.cells[15].value.tostring()); var onemonthbefore = expirationdate.adddays(-30); if (now > onemonthbefore && < expirationdate) { row.defaultcellstyle.backcolor = color.yellow; } else if (now > expirationdate) { row.defaultcellstyle.backcolor = color.red; } } when executing project getting error object reference not set instance of object this whole code particular form please check getting wrong public partial ...