I have up to 5 textboxes that I need to populate with email addresses from a semicolon delimited list. I am getting a NullReferenceException
error:
The text box IDs are: "txtContactEmail1", "txtContactEmail2"
, etc.
var _propinfo = new Upsell().RetrievePropertyInfo(strRatpropid);
strCurrency = _propinfo.currency;
strEmailList = _propinfo.ContactEmail;
string[] emails = Regex.Split(strEmailList, ";");
if (emails.Length > 0) {
foreach (string email_loopVariable in emails) {
if (email_loopVariable != "None Available" || email_loopVariable != "") {
for (int i = 1; i <= 5; i++) {
TextBox t = (TextBox)FindControl("txtContactEmail" + (i)) as TextBox;
t.Text = email_loopVariable;
}
}
}
}
This is the line where I get the exception t.Text = email_loopVariable;
The strEmailList
looks something like this:
"tsmith@myco.com;mjones@myco.com;bharris@myco.com;"
Thanks, in advance for any help I can get with this.