I have a function that returns a list of email addresses from a SQL stored Proc based on an ID called. It is using StringBuilder and returns one column. For most IDs there are 4 or less email addresses and this format is fine. However we are now getting more IDs with 10+ email addresses and this is making the page too long.
The function is:
DataTable dt = DAL.ExecStoredProc(DAL.DatabaseName.DB, "storedProc", param);
StringBuilder sb = new StringBuilder();
sb.Append("<br/><br/>");
sb.Append("<table border='0' cellpadding='3'>");
for (int i = 0; i < dt.Rows.Count; i++)
{
sb.Append("<tr><td>");
sb.Append(dt.Rows[i]["EMail"].ToString());
sb.Append("</td></tr>");
}
sb.Append("</table>");
return sb.ToString();
I have tried using the following but it breaks when there are too few addresses to return:
DataTable dt = DAL.ExecStoredProc(DAL.DatabaseName.DB, "storedProc", param);
StringBuilder sb = new StringBuilder();
sb.Append("<br/><br/>");
sb.Append("<table border='0' cellpadding='3'>");
for (int i = 0; i < dt.Rows.Count; i++)
{
sb.Append("<tr><td>");
sb.Append(dt.Rows[i]["EMail"].ToString());
i++;
sb.Append("</td>");
sb.Append("<td>");
sb.Append(dt.Rows[i]["EMail"].ToString());
i++;
sb.Append("</td>");
sb.Append("<td>");
sb.Append(dt.Rows[i]["EMail"].ToString());
i++;
sb.Append("</td></tr>");
}
sb.Append("</table>");
return sb.ToString();