0

txtIDCardNo.Text = c.IDCardNumber.ToString();

why is it giving me a nullreferenceexception?

Edited by xanawa: n/a

2
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by xanawa
0

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 = "";

Edited by Mitja Bonca: n/a

0

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 :)

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.