[英]Object reference is not set into instance of an object
我正在从数据库表中检索数据。
通过输入为1 in
textbox1(voucherno)-->damagedetail =
web.getdamageddetail(Convert.ToInt32(voucherno.Text));
我想让branchno作为textbox2(branchno)中的输出
branchno.Text = damagedetail.branchno.ToString();
但出现错误
未将对象引用设置为对象实例。
检查我的第二行。
第二行编码正确吗?
damagedetail.branchno
为空。
尝试这个:
if (damagedetail.branchno != null)
branchno.Text = damagedetail.branchno;
else
branchno.Text = "abcd";
要么您的对象属性未填充,否则当您从对象中检索值“ branchno”时,该值等于null;或者您未在“ getdamageddetail”方法中填充该属性
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.