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)
精彩评论