txtIDCardNo.Text = c.IDCardNumber.ToString();
why is it giving me a nullreferenceexception?
txtIDCardNo.Text = c.IDCardNumber.ToString();
why is it giving me a nullreferenceexception?
Becuase you cannot assign a null value to the Text property of the textBox.
You can do a checking if the value is null or not:
if(c.IDCardNumber != null)
txtIDCardNo.Text = c.IDCardNumber.ToString();
else
txtIDCardNo.Text = "";
i found my mistake.. the thing was i was passing through the constructor a null customer and forgot to do the if statement as u told me thx very much :)
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.