我有一个 rad Grid,我正在尝试将其转换为简单的 html,但我显示了一个我不明白要解决的错误这是我的代码
private string getHTML(RadGrid gv)
{
string result;
StringBuilder sb = new StringBuilder();
StringWriter stringwriter = new StringWriter(sb);
HtmlTextWriter htmlwriter = new HtmlTextWriter(stringwriter);
htmlwriter.RenderBeginTag(HtmlTextWriterTag.Html);
htmlwriter.RenderBeginTag(HtmlTextWriterTag.Body);
gv.RenderControl(htmlwriter);
htmlwriter.RenderEndTag();
htmlwriter.RenderEndTag();
htmlwriter.Flush();
result = stringwriter.ToString();
htmlwriter.Close();
stringwriter.Close();
return result;
}
错误在这里
页面不能为空。请确保在 ASP.NET 请求的上下文中执行此操作。
错误就在这一行
gv.RenderControl(htmlwriter);
请任何人给我解决这个问题的想法