Jump to content
Software FX Community

Response.Redirect cannot be called in a Page callback.


Recommended Posts


I've gotten really far along in development of my app, getting ready for final testing and deployment to production.  Thanks for all the help along the way.  I have one final hurdle to overcome.  I need to be able to click on a button on the grid that then prints a SRS report based upon the invoice number in the grid.  When I attempt the following line of code I get the error message Response.Redirect cannot be called in a Page callback. 

Here's my code... (located in Grid1.executingcustomcommand)

dim msg as string

msg = "Http://sqlserver01/reportserver?/MarinaReports/SalesOrder&SalesOrderID=" + cstr(e.gridItem.datavalues.primaryKey.tostring()) + "&rs:Format=pdf&rs:command=Render"



How can I accomplish this feat with your GridFX?


ChartFx_ItemSource Fail.zip

Link to comment
Share on other sites

As you found out, ASP.NET doesn't allow response.redirects in callbacks.  At this time, the custom command always uses callbacks, although a postback option will be added in the future.  Instead of using CommandButton, I would recommend using a regular Button control in a TemplateColumn, then handle its Click event.

Add a template column, edit its template, drag a button, and handle the button's click event in the property grid.  The markup will look something like



Header Template


<ItemTemplate><asp:Button ID="Button1" runat="server" onclick="Button1_Click"

Text="View Report" />



An event handler will be created.  In that handler, you need to get the GridItem that contains the button via the static GridItem.FindContainingItem method.  Then you can do the rest of what you need and Response.Redirect will work great.  Here's a quick C# handler:

protected void Button1_Click(object sender, EventArgs e)


GridItem item = GridItem.FindContainingItem((Control)sender);string link = "http://header" + item.DataValues.PrimaryKey.ToString() + "footer";




Hope this helps.  Let me know how it goes.

Link to comment
Share on other sites

Stephan, Thanks for the update.  As my .Net developer is on vac for the next 2 weeks, could you convert the code to VB.net for me?  Also, I updated the grid to include an asp:imagebutton successfully, but don't see the onclick event.  Where would I find that?


Link to comment
Share on other sites


This topic is now archived and is closed to further replies.

  • Create New...