Skip to main content
added 66 characters in body
Source Link
Access Denied
  • 9.6k
  • 4
  • 47
  • 80

You are missing openning tags, that's why component throws exception, since it reads tagclosing tags which waswere not opened and stack is empty (probably it uses stack to track openning/closing tags):

using (StringWriter sw = new StringWriter()) { using (HtmlTextWriter hw = new HtmlTextWriter(sw)) { StringBuilder sb = new StringBuilder(); sb.Append("<table width='100%' cellspacing='0' cellpadding='2'>"); sb.Append("<tr>"); foreach (DataColumn column in dt.Columns) { sb.Append("<th>"); sb.Append(column.ColumnName); sb.Append("</th>"); } sb.Append("</tr>"); foreach (DataRow row in dt.Rows) { sb.Append("<tr>"); foreach (DataColumn column in dt.Columns) { sb.Append("<td>"); sb.Append(row[column]); sb.Append("</td>"); } sb.Append("</tr>"); } sb.Append("</table>"); 

You are missing openning tags, that's why component throws exception, since it reads tag which was not opened and stack is empty:

using (StringWriter sw = new StringWriter()) { using (HtmlTextWriter hw = new HtmlTextWriter(sw)) { StringBuilder sb = new StringBuilder(); sb.Append("<table width='100%' cellspacing='0' cellpadding='2'>"); sb.Append("<tr>"); foreach (DataColumn column in dt.Columns) { sb.Append("<th>"); sb.Append(column.ColumnName); sb.Append("</th>"); } sb.Append("</tr>"); foreach (DataRow row in dt.Rows) { sb.Append("<tr>"); foreach (DataColumn column in dt.Columns) { sb.Append("<td>"); sb.Append(row[column]); sb.Append("</td>"); } sb.Append("</tr>"); } sb.Append("</table>"); 

You are missing openning tags, that's why component throws exception, since it reads closing tags which were not opened and stack is empty (probably it uses stack to track openning/closing tags):

using (StringWriter sw = new StringWriter()) { using (HtmlTextWriter hw = new HtmlTextWriter(sw)) { StringBuilder sb = new StringBuilder(); sb.Append("<table width='100%' cellspacing='0' cellpadding='2'>"); sb.Append("<tr>"); foreach (DataColumn column in dt.Columns) { sb.Append("<th>"); sb.Append(column.ColumnName); sb.Append("</th>"); } sb.Append("</tr>"); foreach (DataRow row in dt.Rows) { sb.Append("<tr>"); foreach (DataColumn column in dt.Columns) { sb.Append("<td>"); sb.Append(row[column]); sb.Append("</td>"); } sb.Append("</tr>"); } sb.Append("</table>"); 
Source Link
Access Denied
  • 9.6k
  • 4
  • 47
  • 80

You are missing openning tags, that's why component throws exception, since it reads tag which was not opened and stack is empty:

using (StringWriter sw = new StringWriter()) { using (HtmlTextWriter hw = new HtmlTextWriter(sw)) { StringBuilder sb = new StringBuilder(); sb.Append("<table width='100%' cellspacing='0' cellpadding='2'>"); sb.Append("<tr>"); foreach (DataColumn column in dt.Columns) { sb.Append("<th>"); sb.Append(column.ColumnName); sb.Append("</th>"); } sb.Append("</tr>"); foreach (DataRow row in dt.Rows) { sb.Append("<tr>"); foreach (DataColumn column in dt.Columns) { sb.Append("<td>"); sb.Append(row[column]); sb.Append("</td>"); } sb.Append("</tr>"); } sb.Append("</table>");