Update your code as below.
for (int i = 0; i < dg.Rows.Count; i++)
{
strB.AppendLine("<table><tbody><tr>");
for(int j=0;j<dg.columns.count;j++)>
{
[B]strB.AppendLine("<td align="center" valign="middle">" +
dg.Rows[i].Cells[j].ToString() + "</td>");[/B]
}
strB.AppendLine("</tr></tbody></table>");
}
Hope this will help you.