Monday, 8 July 2013

Datatable using datarow & datacolumn to fecth data to send mail (adding in string Builder)

Ans 1.
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();

Ans 2.
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>");
    sb
.Append("<td>");
    sb
.Append(dt.Rows[i]["EMail"].ToString());
    sb.Append("</td>");
    sb
.Append("<td>");
    sb
.Append(dt.Rows[i]["EMail"].ToString());
    sb.Append("</td></tr>");
}
sb
.Append("</table>");
return sb.ToString();

No comments:

Post a Comment