的GridView必须被添加到一个表格标签用于呈现 [英] GridView must be added to a form tag for rendering

查看:104
本文介绍了的GridView必须被添加到一个表格标签用于呈现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

TextWriter tr = new StringWriter();
HtmlTextWriter writer = new HtmlTextWriter(tr);
HtmlForm form = new HtmlForm();
form.Controls.Add(divQueryDescription);
divQueryDescription.RenderControl(writer);

<div runat="server" id="divQueryDescription">
    <asp:GridView runat="server" id="grv"></asp:GridView>
</div>

我的GridView是一个DIV里面,我补充一点,DIV到的HtmlForm,这样我可以把它呈现为一个字符串。但我得到以下错误: -

My GridView is inside a DIV and I add that DIV to an HtmlForm, so that I can render it to a string. But I get the following error:-

GridView的'GRV'必须放在与RUNAT =服务器的形式标记中,虽然我的GridView已经是一个形式里面,因为我加了我的DIV的形式。

Gridview 'grv' must be placed inside a form tag with runat=server, although my Gridview is already inside a form because I added my DIV to the form.

我怎样才能使这个DIV为一个字符串?

How can I render this DIV to a string ?

推荐答案

只需添加以下code。在您的网页

Just add the following code in your page

public override void VerifyRenderingInServerForm(Control control)
{
  return;
}

要了解更多内容,请阅读 MSDN文档

To learn more about it, read the MSDN documentation.

这篇关于的GridView必须被添加到一个表格标签用于呈现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆