1
我需要在GridView的ItemCommand_click
事件的RunTime期間生成一個Excel工作表,然後傳輸該文件,然後重新綁定GridView和狀態更改。使用GridView和文件傳輸
當我們通過文件傳輸重定向響應時,如何更新GridView?
我需要在GridView的ItemCommand_click
事件的RunTime期間生成一個Excel工作表,然後傳輸該文件,然後重新綁定GridView和狀態更改。使用GridView和文件傳輸
當我們通過文件傳輸重定向響應時,如何更新GridView?
我正在尋找在行上選定的索引更改上非常類似的東西,以將報告服務報告輸出爲PDF。我只能通過response.redirect來處理文件輸出的另一個頁面。看起來你的問題真的變成了在狀態改變之後重新綁定網格,如果你做了response.redirect,你不能碰你的網格......
看看這段代碼。我發現它在encosia.com。它看起來像你可能能夠使用iFrame輸出,然後你可以使用JavaScript調用回發頁面來重新綁定網格。
<html>
<body>
<form id="form1" runat="server">
<asp:ScriptManager runat="server" />
<script language="javascript">
// Get a PageRequestManager reference.
var prm = Sys.WebForms.PageRequestManager.getInstance();
// Hook the _initializeRequest event and add our own handler.
prm.add_initializeRequest(InitializeRequest);
function InitializeRequest(sender, args)
{
// Check to be sure this async postback is actually
// requesting the file download.
if (sender._postBackSettings.sourceElement.id == "DownloadFile")
{
// Create an IFRAME.
var iframe = document.createElement("iframe");
// Get the desired region from the dropdown.
var region = $get("Region").value;
// Point the IFRAME to GenerateFile, with the
// desired region as a querystring argument.
iframe.src = "GenerateFile.aspx?region=" + region;
// This makes the IFRAME invisible to the user.
iframe.style.display = "none";
// Add the IFRAME to the page. This will trigger
// a request to GenerateFile now.
document.body.appendChild(iframe);
}
}
</script>
<asp:UpdatePanel runat="server">
<ContentTemplate>
<asp:DropDownList runat="server" ID="Region">
<asp:ListItem Value="N">North Region</asp:ListItem>
<asp:ListItem Value="W">West Region</asp:ListItem>
<asp:ListItem Value="SE">Southeast Region</asp:ListItem>
</asp:DropDownList>
<asp:Button runat="server" ID="DownloadFile" Text="Generate Report" />
</ContentTemplate>
</asp:UpdatePanel>
</form>
</body>
</html>
處理該下載頁面...
protected void Page_Load(object sender, EventArgs e)
{
string FileResponse;
string Region = Request.QueryString["Region"];
// Code here to fill FileResponse with the
// appropriate data based on the selected Region.
Response.AddHeader("Content-disposition", "attachment; filename=report.csv");
Response.ContentType = "application/octet-stream";
Response.Write(FileResponse);
Response.End();
}
邏輯lloks好......會嘗試這一個 BTW我想的,而創造了文件處理的的.aspx,我們可以去.ashx(HTTP處理程序); wat說? – Novice 2009-02-24 22:11:50