I am trying to make a simple report. The problem is:
--I need to output the report on the webpage with a button that allows the data to have a "Save As" option
The ASPX page uses a "Submit" button to create data and display it below. It's simple. It works.
<asp:Repeater runat="server" ID="rptTableView">
<ItemHeader>
<tr>
<td><%#DataBinder.Eval(Container.DataItem, "item1") %><td>
<td><%#DataBinder.Eval(Container.DataItem, "item2") %></td>
<td><%#DataBinder.Eval(Container.DataItem, "item3") %></td>
<td><%#DataBinder.Eval(Container.DataItem, "item4") %></td>
</tr>
</ItemHeader>
</asp:Repeater>
But when I try to use the "Generate Report" button:
protected void btnGenerate_Click(object sender, EventArgs e)
{
Response.Clear();
Response.Buffer = true;
Response.ContentType = "text/csv";
Response.AddHeader("content-disposition", "attachment;filename=" + filename);
Response.Write(dataOut);
Response.End();
}
As expected: the Response.ContentType causes new data to be generated on the server and is pushed to the "User/Downloads" folder and NOT on the webpage.
I need the data generated to show on the page first and, if the user wants, allow that data to "Save As."
Help!
I've scoured the internet for the past week trying to do this.