向文本框添加值会出现异常 "object reference not set to an instance of an object"
Adding value to text Box goes to exception "object reference not set to an instance of an object"
我正在处理一个 .NET 项目,我应该在其中从 Web 服务获取数据,然后在 telerik 报告中显示这些数据。问题是我的代码出现异常 "object reference not set to an instance of an object."
public CertifikatePersonale(string ssn)
{
string COUNTY = null;
string FATHER_NAME = null;
try
{
ArrayList list = new ArrayList();
SkyServices service = new SkyServices();
object [] merrcertifikate = getPerCertificate(ssn);
for (int i = 0; i < merrcertifikate.Length; i++)
{
string SSN = ((string)(merrcertifikate[1]));
string LAST_NAME = ((string)(merrcertifikate[2]));
FATHER_NAME = ((string)(merrcertifikate[3]));
string ADDRESS = ((string)(merrcertifikate[4]));
string GENDER = ((string)(merrcertifikate[5]));
string BIRTH_PLACE = ((string)(merrcertifikate[6]));
string BIRTH_DATE = ((string)(merrcertifikate[7]));
string MOTHER_NAME = ((string)(merrcertifikate[8]));
string MARITAL_STATUS = ((string)(merrcertifikate[9]));
COUNTY = ((string)(merrcertifikate[10]));
string DOCUMENT_TYPE = ((string)(merrcertifikate[11]));
string DOCUMENT_ISSUE_DATE = ((string)(merrcertifikate[12]));
string DOCUMENT_EXPIRATION_DATE = ((string)(merrcertifikate[13]));
string RESPONSE = ((string)(merrcertifikate[14]));
string RESPONSE_DATA = ((string)(merrcertifikate[15]));
}
txb_Nation.Value = COUNTY.ToString().ToUpper();
}
catch { }
}
行
txb_Nation.Value = COUNTY.ToString().ToUpper();
即使 County 有值也会导致异常。
请帮忙,这花费的时间比应该的多。谢谢
如果COUNTY
真的有值,那么一定是txb_Nation
没有初始化。您的代码没有显示该引用的来源;检查它的值是否设置正确。
试试这个:
txb_Nation.Value = COUNTY==null?"":COUNTY.ToString().ToUpper();
我正在处理一个 .NET 项目,我应该在其中从 Web 服务获取数据,然后在 telerik 报告中显示这些数据。问题是我的代码出现异常 "object reference not set to an instance of an object."
public CertifikatePersonale(string ssn)
{
string COUNTY = null;
string FATHER_NAME = null;
try
{
ArrayList list = new ArrayList();
SkyServices service = new SkyServices();
object [] merrcertifikate = getPerCertificate(ssn);
for (int i = 0; i < merrcertifikate.Length; i++)
{
string SSN = ((string)(merrcertifikate[1]));
string LAST_NAME = ((string)(merrcertifikate[2]));
FATHER_NAME = ((string)(merrcertifikate[3]));
string ADDRESS = ((string)(merrcertifikate[4]));
string GENDER = ((string)(merrcertifikate[5]));
string BIRTH_PLACE = ((string)(merrcertifikate[6]));
string BIRTH_DATE = ((string)(merrcertifikate[7]));
string MOTHER_NAME = ((string)(merrcertifikate[8]));
string MARITAL_STATUS = ((string)(merrcertifikate[9]));
COUNTY = ((string)(merrcertifikate[10]));
string DOCUMENT_TYPE = ((string)(merrcertifikate[11]));
string DOCUMENT_ISSUE_DATE = ((string)(merrcertifikate[12]));
string DOCUMENT_EXPIRATION_DATE = ((string)(merrcertifikate[13]));
string RESPONSE = ((string)(merrcertifikate[14]));
string RESPONSE_DATA = ((string)(merrcertifikate[15]));
}
txb_Nation.Value = COUNTY.ToString().ToUpper();
}
catch { }
}
行
txb_Nation.Value = COUNTY.ToString().ToUpper();
即使 County 有值也会导致异常。 请帮忙,这花费的时间比应该的多。谢谢
如果COUNTY
真的有值,那么一定是txb_Nation
没有初始化。您的代码没有显示该引用的来源;检查它的值是否设置正确。
试试这个:
txb_Nation.Value = COUNTY==null?"":COUNTY.ToString().ToUpper();