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

Popular posts from this blog

c# - SelectList with Dictionary, add values to the Dictionary after it's assigned to SelectList -

how can i manage url using .htaccess in php? -

ios - I get the error Property '...' not found on object of type '...' -