-8

This is an old project of mine. i haven't opened it for some time. As far as i remember it was working perfectly fine. but today when i opend it it stopped working. i haven't change a single line of code. it just stopped working(it builds just fine but dont start after). After a full night of frustration i found the reason of why its not starting but couldn't imagine or find any possible solution, cause it was eorking perfectly fine but suddenly it decided to stop working. Please help :)

i have no idea why this exception is showing now. the code was running perfectly before

i swear i haven't changed a single line of code. not even a coma.

Jeremy Thompson
  • 61,933
  • 36
  • 195
  • 321
  • 2
    A few tips on how to use Stackoverflow, a) Never post screenshots of code, b) explain the problem not "I swear I didn't change anything" three times over. c) focus on one problem its irrelevant that you had problems starting the project to the error you're now experiencing. – Jeremy Thompson Mar 30 '22 at 00:47
  • Please [edit] your post with a [mre]. There is not enough information to properly solve your issue. – gunr2171 Mar 30 '22 at 00:53

1 Answers1

2

It's because you have called PopulateGridViewEmployee with an empty searchKey which is an Optional Argument set to Null.

Hence you're getting System.ArgumentNullException

To fix it change the optional argument to have an empty string:

PopulateGridViewEmployee(string searchKey = "")

Jeremy Thompson
  • 61,933
  • 36
  • 195
  • 321
  • i set it to null for a default search value. i have tried your solution too but it doesn't work. if (key == null) sql = "select * from Employee;"; else sql = "select * from Employee where EmpId like '%" + key + "%' or EmpName like '%" + key + "%';"; here is the argument for that – Rahamatullah sun Mar 30 '22 at 00:50
  • Can you please [edit] your question and paste in the code, including the PopulateGridViewEmployee method. – Jeremy Thompson Mar 30 '22 at 00:54