zs2020
zs2020

Reputation: 54514

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 exception 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"

Upvotes: 1

Views: 1134

Answers (2)

Ishaque Adoni
Ishaque Adoni

Reputation: 11

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);``

Upvotes: 1

Chingiz Musayev
Chingiz Musayev

Reputation: 2962

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)

Upvotes: 0

Related Questions