开发者

Exception when generating an Excel document from a Repeater in asp.net

I have pretty much followed this thread Export to Excel from a Repeater?, however, I get an exc开发者_如何学JAVAeption saying

155|error|500|Control 'XXX' of type 'LinkButton' must be placed inside a form tag with runat=server.|

The LinkButton is defined in the HeaderTemplate, so how do I fix this problem?

Updated: The form tag is in the master page with runat="server"


When You have Repeater control on the Master page and in that repeater control if you have Linkbutton or any other controls so you can use this code it may help you..I have used this code in Export to Excel

form.Controls.Add(this.rptChDashboard);

        this.Controls.Add(form);

        form.RenderControl(htmlTextWrite);``


How it is said in the exception. "Place control inside a form tag with runat=server."

<form runat="server">
   <asp:Repeater>
      ...
   </asp:Repeater>
</form>

Or do some magic with Page.VerifyRenderingInServerForm (not recommended)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜