I have a ExtendedGridView that inherits from GridView and has a PagerRow.
In this pagerRow i have a PageSize selector (DDL) , the page navigation controls and now an Export to Excel button.
This button creates a OOXML Excel file and then transmits it through Page.Response.BinaryWrite from a MemoryStream.
The thing here is that I can't use the Page.Response.BinaryWrite in a Partial PostBack, so I have to declare a trigger for this button in the outer UpdataPanel so it does a Full Postback.
But as the button is inside the "PagerRow Template" for the gridView and is not always visible/rendered on the page, the Trigger element throws an exception.
Has anyone has an ideia how to work around this issue?
I've tried those approaxes but while the actual button is inside an Gridview's PagerRow, which is inside a panel, the panel trigger list doesn't find the control.
I've created an SyncImageButton that inherits ImageButton, and has a custom Property "AsynchronousCallback", which is false by default.
Then i overriden the "PreRender" and place the following code:
Infospy
Member
10 Points
8 Posts
asp:UpdatePanel , GridView, GridView PagerRow
Feb 28, 2012 02:24 PM|LINK
Hi!
I have a ExtendedGridView that inherits from GridView and has a PagerRow.
In this pagerRow i have a PageSize selector (DDL) , the page navigation controls and now an Export to Excel button.
This button creates a OOXML Excel file and then transmits it through Page.Response.BinaryWrite from a MemoryStream.
The thing here is that I can't use the Page.Response.BinaryWrite in a Partial PostBack, so I have to declare a trigger for this button in the outer UpdataPanel so it does a Full Postback.
But as the button is inside the "PagerRow Template" for the gridView and is not always visible/rendered on the page, the Trigger element throws an exception.
Has anyone has an ideia how to work around this issue?
Best regards,
Vitor Monteiro
chetan.sarod...
All-Star
66639 Points
11275 Posts
Re: asp:UpdatePanel , GridView, GridView PagerRow
Feb 29, 2012 02:43 AM|LINK
http://nice-tutorials.blogspot.in/2009/06/export-gridview-to-excel-within-update.html
http://jinath.wordpress.com/2008/02/18/export-gridview-to-excel-inside-an-update-panel/
Senior Software Engineer,
Approva Systems Pvt Ltd, Pune, India.
Infospy
Member
10 Points
8 Posts
Re: asp:UpdatePanel , GridView, GridView PagerRow
Feb 29, 2012 09:18 AM|LINK
Thank you for your help.
I've tried those approaxes but while the actual button is inside an Gridview's PagerRow, which is inside a panel, the panel trigger list doesn't find the control.
I've created an SyncImageButton that inherits ImageButton, and has a custom Property "AsynchronousCallback", which is false by default.
Then i overriden the "PreRender" and place the following code:
public bool AsynchronousCallback
{
get
{
if (ViewState["AsynchronousCallback"] != null)
{
return (bool)ViewState["AsynchronousCallback"];
}
else
return false;
}
set
{
ViewState["AsynchronousCallback"] = value;
}
}
protected override void OnPreRender(EventArgs e)
{
base.OnPreRender(e);
if (!AsynchronousCallback)
{
ScriptManager scriptMan = ScriptManager.GetCurrent(this.Page);
if (scriptMan != null)
{
scriptMan.RegisterPostBackControl(this);
}
}
}
So, it will register with page's ScriptManager, case it is not null and case AsynchronousCallback is false.