开发者

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

开发者 https://www.devze.com 2023-02-09 00:31 出处:网络
I have pretty much followed this thread Export to Excel from a Repeater?, however, I get an exc开发者_如何学JAVAeption saying

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

精彩评论

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