asp.net - Unable to render Grid View -
i have grid view in user control, , getting below error:
registerforeventvalidation can called during render();
i using gv.rendercontrol(htw);
my code below:
private void exporttoexcel(string strfilename, gridview gv) { response.clearcontent(); response.addheader("content-disposition", "attachment; filename=" + strfilename); response.contenttype = "application/excel"; system.io.stringwriter sw = new system.io.stringwriter(); htmltextwriter htw = new htmltextwriter(sw); gv.rendercontrol(htw); response.write(sw.tostring()); response.end(); }
and avoid server control created outside form control exception using below code:
public override void verifyrenderinginserverform(control control) { /* verifies control rendered */ }
but i'm using code in usercontrol, there isn't method in base class. should do, placed above in page in place user control, still getting above error
also note using masterpage in have form tagged already.
setting enableeventvalidation in page directive false solved problem.
<%@ page ............ enableeventvalidation="false" %>
Comments
Post a Comment